help me in this query.....

  • Please help me regarding Query to find second largest number in the column....

  • Hi,

     

    Try something like:

     

    select max( column-Name )

    from table-Name

    where column-Name <

        (

        select max( column-Name )

        from table-Name

        )

     

    Regards

      David

     

  • This would work too..

    select top 1 *

    from

    (select top 2 [value_to_compare],[other_fields]

    from foo

    order by [value_to_compare] desc

    )q

    order by [value_to_compare] asc

    if you wanted the third item you would change 2 to 3 ..etc

    HTH

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply