======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
select * from tbl t1 where val = (select max(val) from tbl t2 where t2.fld = t1.fld)
union all
select * from tbl t1 where val = (select max(val) from tbl t2 where t2.fld = t1.fld and val < (select max(val) from tbl t2 where t2.fld = t1.fld))
or
select * from tbl t1 where val in (select top 2 val from tbl t2 where t2.fld = t1.fld order by val desc)
Be careful about duplicate val's
======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.