CASE Usage in SQL
Problem: Write a query using the following table. The requirement is, result all the details " less than 20000" in ascending order and salary "greater than 20000" in descending order
Query is:
Select * FromOrder by (Case When Salary <= 20000 Then -Salary Else null end) DESC,(Case When Salary > 20000 Then -Salary Else null end)
Name | Salary |
Karthik | 25000 |
Samuel | 32000 |
John | 17000 |
Murali | 28000 |
Syam | 15000 |
Output should be
Name | Salary |
Syam | 15000 |
John | 17000 |
Samuel | 32000 |
Murali | 28000 |
Karthik | 25000 |
Query is:
Select * From
Comments