Lets say i have the table sales
+------------+---------+------------------------------+-------------+
| SaleAmount | OrderID | CompanyName | ShippedDate |
+------------+---------+------------------------------+-------------+
| 3302 | 10393 | Save-a-lot Markets | 1997-01-03 |
| 2736 | 10398 | Save-a-lot Markets | 1997-01-09 |
| 3063 | 10400 | Eastern Connection | 1997-01-16 |
if i query with aggregate function
select max(saleamount),shippeddate from sales where shippeddate = '1997-01-16'
group by shippeddate
It will display the max of sale amount for the particular date. here i want to show the top n max values for the particular date. this i can achieve by doing the same using subquery or storing in table like below
select * from
(select * from sales h order by shippeddate, saleamout) where shippeddate = '1997-01-16' and rownum <= 2
Is there any other way to display the top n (max,min) values or any way to write the multirow functions.
EDIT:
here i don't want to use the subquery where the buffer size is too low and it takes larger time for execution time. My database is oracle 11g