Second Largest

  • Hi Experts,

    How to find the second largest value from a column??

  • [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]

  • 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