![]() |
| ||
| Sql query to get max 5 values Hi , Can we have an sql query to get the max 5 values from a column? Please paste a sample code if its possible. Thanks in advance. |
| ||
| Re: Sql query to get max 5 values Got the soln, as below select * from (select a from <tbl> order by a DESC) where rownum<=5; Thanks. |
| ||
| Re: Sql query to get max 5 values select * from <tab> where rownum <=5 I dont think extra subquery is needed here. pls correct me if m wrong. |
| ||
| Re: Sql query to get max 5 values Yes buddy, the extra sub querry is needed, as in below case : select * from <tab> where rownum <=5 the first 5 rown are getting sorted and then ordered, which would not essesntaily return max 5 values. However if we use it as : select * from (select a from <tbl> order by a DESC) where rownum<=5; the results are first ordered in desceding order i.e max to lowest and on selecting the frist 5 rows, we get the 5 max values. |
| ||
| Re: Sql query to get max 5 values @ iceman Thanx pal for correcting me |
| ||
| Re: Sql query to get max 5 values Excellent stuff mate... Thanks a ton! |
| All times are GMT -4. The time now is 2:53 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC