How Create Sum for Sort?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a list of donors. I need to sort them on the total value of their
gifts. Some have made one gift, others have made more. When sorted on donor
name, some donors have one record (they made one gift) and others have
multiple records (multiple gifts.)

How do I do this? Help!

Fields: Donor, Gift
 
David said:
I have a list of donors. I need to sort them on the total value of their
gifts. Some have made one gift, others have made more. When sorted on donor
name, some donors have one record (they made one gift) and others have
multiple records (multiple gifts.)

How do I do this? Help!

Fields: Donor, Gift

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Highest donor first:

SELECT Donor, Gift
FROM table_name
ORDER BY Gift DESC


In donor order, w/ donor's highest donation first:

SELECT Donor, Gift
FROM table_name
ORDER BY Donor, Gift DESC


Highest total values first:

SELECT Donor, SUM(Gift) As TotalGifts
FROM table_name
GROUP BY Donor
ORDER BY 2 DESC

The clause ORDER BY 2 DESC means sort the TotalGifts column (column 2)
in descending order (highest first).
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRAN++oechKqOuFEgEQJfzACdGD0VkztCzuLuYpyQe81e/VkCkU4AoP4J
6h6yzhxZ8E9UrZGYjVXXWgwi
=kuCA
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top