Please visit our sponsor
UNKNOWN --************************************** -- Name: nth largest/smallest from a table -- Description:To find Nth largest and Smallest 'value'(Numbers) from a Table. -- By: MuraliKrishna Vedagiri -- -- -- Inputs:The N: The index of the largest/smallest number. -- -- Returns:Largest / Smallest -- --Assumes:SImple SQL knowledge -- --Side Effects:None --This code is copyrighted and has limited warranties. --Please see http://www.Planet-Source-Code.com/xq/ASP/txtCodeId.374/lngWId.5/qx/vb/scripts/ShowCode.htm --for details. --************************************** select a.itemid from item a where (n-1) = (select count(*) from item b where b.itemid > a.itemid) /** By changing > to < you can get Smallest Number ** ** If you want to find the 4th largest, then 4-1 =3 in place of (n-1)/