sql - How to select maximum value of two identical columns in same table? -
id1 id2 name 1 1 2 2 3 4 b 3 5 6 c 4 7 8 d 5 9 10 e select id1, id2, name emp3 id2 in (select max(id2) emp3)
how can print maximum number?
use
select id2 emp3 id2 in (select max(id2) emp3)
this print 10
if want maximum among 2 columns use
select case when max(id1) >= max(id2) max(id1) when max(id2) >= max(id1) max(id2) end maxvalue emp3
Comments
Post a Comment