Selection of aa, bb, cc, dd four fields, I want to get the following results: the four fields, all data for a null value is 1, two null values are 2 data, have a null value is 1 the data, without an empty value data have 1
Rookie help great god answer, thank you very much!
CodePudding user response:
Select
Null=(case when aa="' then one else 0 end
+ case when bb="' then one else 0 end
+ case when cc="' then one else 0 end
+ case when dd="' then one else 0 end
+ case when ff="' then one else 0 end)
, * from table
The order by (case when aa="' then one else 0 end
+ case when bb="' then one else 0 end
+ case when cc="' then one else 0 end
+ case when dd="' then one else 0 end
+ case when ff="' then one else 0 end)