I want to sort column2 based on Column1 values. I want split column1 data based on NULL value. The final query result will be displayed on evaluating the values in the column1
Column1 Column2
NULL 100
NULL 60
NULL 90
10 22
20 40
05 35
15 20
40 10
30 25
20 30
Would become:
Column1 Column2
20 40
05 35
20 30
30 25
10 22
15 20
40 10
NULL 100
NULL 90
NULL 60
Thanks
You can use case in your order by
clause like this:
Select * from t
Order by case when column1 is null then 1 else 0 end, column2 desc
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments