Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
rohitsamnotra
Starting Member
1 Post |
Posted - 2013-05-10 : 23:24:34
|
how to find 50th lowest value in a table using sql query ,, please help me out ,Reply soon |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2013-05-11 : 00:04:17
|
[code]With cte AS ( SELECT someColumn, row_number() over (order by someColumn) ix FROM YourTable)SELECT someColumnFROM cteWHERE ix = 50;[/code] |
|
|
MuMu88
Aged Yak Warrior
549 Posts |
Posted - 2013-05-11 : 11:15:59
|
Or you can try this:[CODE]SELECT column_name FROM table_name ORDER BY column_name OFFSET 49 ROWS FETCH NEXT 1 ROWS ONLY;[/CODE] |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-13 : 00:45:03
|
quote: Originally posted by MuMu88 Or you can try this:[CODE]SELECT column_name FROM table_name ORDER BY column_name OFFSET 49 ROWS FETCH NEXT 1 ROWS ONLY;[/CODE]
Works only from SQL 2012 onwards------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-13 : 00:46:55
|
[code]SELECT someColumnFROM Table tWHERE 49 = (SELECT COUNT(*) FROM table WHERE someColumn > t.someColumn )[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|