sql - Implementing NULLS FIRST in Amazon Redshift -
i using sum window function row number, similar query -
select field_a, sum(1) on (partition field_b order field_c asc rows unbounded preceding) row_number test_table order row_number; the problem if field_c null value, appears @ end. want @ beginning, null value treated smaller other values. in oracle, done providing nulls first argument, not supported in redshift. how implement in redshift ?
i want [null] @ beginning, null value treated smaller other values.
use expression
field_c not null as first order by item. evaluates ...
false .. if null
true .. if not null.
and false (0) sorts before true (1). works data type , possible distribution of values.
select field_a, row_number() on (partition field_b order field_c not null, field_c) row_number test_table order row_number;
Comments
Post a Comment