VastSQL
SSC-Dedicated
Points: 36121
More actions
August 1, 2008 at 1:52 am
#154577
Hi Experts,
How to find the second largest value from a column??
Vidhya Sagar
SSCrazy Eights
Points: 8216
August 1, 2008 at 3:32 am
#851712
[font="Verdana"]You can try the below query, but this will also display the first largest value too.
SELECT top 2 col1 FROM tablename ORDER BY col1 DESC [/font]
Regards..Vidhya SagarSQL-Articles
steveb.
SSC-Forever
Points: 46733
August 1, 2008 at 3:50 am
#851722
another way..
WITH TableOrdered as
(SELECT Col1, Col2 , ROW_NUMBER() OVER (ORDER BY Col1) AS TheOrder
FROM YourTable)
select Col1,Col2 from TableOrdered
where theorder = 2
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply