|
| Total Answers and Comments: 10 |
Last Update: October 28, 2009 |
|
| | |
|
Submitted by: Ravi B This is another simpler alternative: SELECT customer_no, payments FROM (SELECT customer_no, payments FROM customer C1 ORDER BY payments DESC) WHERE ROWNUM <4;
Above answer was rated as good by the following members: bhatnagar_neeraj | |
August 18, 2009 11:33:00 | #9 |
| ketansnadar |
|
Member Since: August 2009 Contribution: 1 |
RE: Suppose a customer table is having different columns like customer no, payments.What will be the query to select top three max payments?
| | Situation 1 : If the payments and the customer no are having single records then use this
SELECT top 3 * FROM Customer Order by Parments DESC
If the payments and the customer no are having more records and you want to sum up the payments and the retrieve then use this
SELECT TOP 3 [CustomerNo] SUM(Payments) FROM Customer group by [CustomerNo] order by sum(Payments) desc
|  | | Is this answer useful? Yes | No | | |
|
| |
Go To Top
|