Skip to content
Advertisement

Tag: amazon-redshift

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.

Aggregating two values in same select statement. Second aggregation is decreasing in value for each row for some reason

I’m currently trying to aggregate two values simultaneously in one select statement; however, the second aggregated value is decreasing for some reason. I know what I’m doing is wrong, but I don’t understand why it’s wrong (assuming it’s the very last code block). Mainly just trying to better understand what’s going on, and why it’s happening. I already have a

Advertisement