By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,266 Members | 1,297 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,266 IT Pros & Developers. It's quick & easy.

Sql Query

P: 1
I have the following table:

Division district amount
_________________________
3 Bhopal 10
3 Sehore 200
3 Vidisha 100
1 Jabalpur 1000
1 Katni 2000
1 mandla 4000
2 indore 25000
2 khandwa 3560
2 khargone 400

How do I write sql query which could display the result set having sum(amount)
group by Division in descending order i.e resultset should be like this
Division district amount
____________________________
2 indore 25000
2 khandwa 3560
2 khargone 400
1 Jabalpur 1000
1 Katni 2000
1 mandla 4000
3 Bhopal 10
3 Sehore 200
3 Vidisha 100
Sep 16 '08 #1
Share this Question
Share on Google+
1 Reply


code green
Expert 100+
P: 1,726
Please explain in what order is this
Expand|Select|Wrap|Line Numbers
  1. Division district amount
  2. 2 indore   25000
  3. 2 khandwa  3560
  4. 2 khargone 400
  5. 1 Jabalpur 1000
  6. 1 Katni    2000
  7. 1 mandla   4000
  8. 3 Bhopal   10
  9. 3 Sehore   200
  10. 3 Vidisha  100
I cannot see a pattern.
You will need something like GROUP BY Division ORDER BY amount DESC
Sep 16 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.