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
Post a Comment