sql - How to find least of two columns and order by the result? -


i find least of 2 columns. did following..

select sname, least(nvl(m1,9999999),nvl(m2,9999999)) "least mark" student; 

but now, order results least mark couldn't do..

select sname, least(nvl(m1,9999999),nvl(m2,9999999)) "least_mark" student order least_mark; 

since there no such column called least_mark existing in table.

you can use subquery:

select s.* (select sname, least(nvl(m1,9999999),nvl(m2,9999999)) least_mark       student      ) s order least_mark; 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -