Skip to content
Advertisement

Tag: cross-join

SQL: Retrieve missing values from superset

I have a table like this: I want to return a table with all the ratings possible. In this case 1 to 5. So my resulting table will be: I have tried using something like: but this does not work. Can you please suggest a solution for this? Answer You can cross join the list of distinct devices with numbers

PostgreSQL cross join using max returns null

I want to select the max() value of the modified_at column in each of several tables: This works correctly as long as each of the tables has at least 1 row. The problem is that when just one of the tables has 0 rows, null is returned for all tables: What is a solution that returns the correct values for

Advertisement