Wednesday, February 25, 2009

SQL Server - Finding 5th maximum value of a table

Gurus,

This SQL Script will help us to find the 5th biggest value from the table.

Here I am using Products table from Northwind database. We can use this query to find any number of value. I have chosen UnitPrice column to find 5th biggest value in it.

select MIN(UnitPrice)
from( select top 5 [UnitPrice] from Products order by UnitPrice desc) as a1

This query will result "123.7900" in SQL Server2000 by default.

CheersGurus!!!
HRK

No comments:

Post a Comment