Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to get the sql result in reverese from the columns in sql

i have been asked a question in interview

sample table name test

A|| B
---------- -
1 | a
2 | b
3 | c
4 | d

o/p:….

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading