Replace NULL values per partition

I want to fill NULL values in device column for each session_id with an associated non-NULL value. How can I achieve that? Here is the sample data: +————+——-+———+ | session_id | step …

How to force postgres to return 0 even if there are no rows matching query, using coalesce, group by and join

I’ve been trying hopelessly to get the following SQL statement to return the query results and default to 0 if there are no rows matching the query. This is the intended result: vol | year ——…