i have been asked a question in interview
sample table name test
A|| B
---------- -
1 | a
2 | b
3 | c
4 | d
o/p:….
A || B
------- -
1 | d
2 | c
3 | b
4 | a
how to to get the desired output ?
>Solution :
You just need to use order by on column B ASC|DESC
SELECT ROW_NUMBER() over (order by Testcol DESC) as A, B
FROM Table
ORDER BY B DESC;