Skip to content

Finding daily registered users

I have a table which includes the information of player_id, first_timestamp, last_timestamp, and date, etc. So I have initially 10 payers on 2020-07-08, and then 18 players on 2020-07-09, some of the players from previous day might appear on 2020-07-09 again. And I’m trying to find the new players regis…

WHERE a AND b returns just WHERE b

I have 2 tables which I want to join and return only those records which: Have the same value with other records in one of the columns. Have certain values in other column. These are my requests: List only those records which have the same value with other records in grnz column: List only those records which…

SQL subquery to find overlapping customers

I’m working on writing a SQL query that would allow me to find customers who bought a certain variety of a product during specific sale dates and then subsequently bought a different product within a different date range. I want to use a subquery in the from clause to search for the second group of cust…

Count NULL values by column in SQL

Suppose I have the following table: How can I count the number of NULL values by each column? My final result would be: Answer You can use union all: Redshift is a column-store database, so there probably is not a more efficient method.

How to group rows in SQL with a special condition?

I have a table like this in my database: I have to write a SQL-Query that selects every month that does not contain “content” at least once. And it should only give out one line. So the output should be like this: How can I accomplish that with a SQL-Query? I tried to do that with the group by fun…