467,134 Members | 944 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,134 developers. It's quick & easy.

Sql Query

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
  • viewed: 796
Share:
1 Reply
code green
Expert 1GB
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.

Similar topics

2 posts views Thread by jaysonsch | last post: by
9 posts views Thread by netpurpose | last post: by
3 posts views Thread by Harvey | last post: by
4 posts views Thread by Diamondback | last post: by
14 posts views Thread by Dave Thomas | last post: by
4 posts views Thread by Stan | last post: by
6 posts views Thread by jsacrey@comcast.net | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.