[UPHPU] MySQL query to get totals
Wade Preston Shearer
lists at wadeshearer.com
Sun Sep 28 10:02:54 MDT 2008
I have an MySQL table that looks like this:
primary key | ID | date
----------+--+------------
1 | 1 | 2008-09-09
2 | 1 | 2008-09-10
3 | 2 | 2008-09-09
4 | 2 | 2008-09-13
…where ID is a reference to something that happens multiple times.
I want to to display the content of the table like this:
ID 1: (sum of all rows with ID 1)
ID 2: (sum of all rows with ID 2)
ID 3: (sum of all rows with ID 3)
…or exactly how it would look…
1: 5
2: 2
3: 16
…etc.
I can do this by performing a query for each ID, but would like to
know if it is possible to retrieve all of the data with a single query.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2425 bytes
Desc: not available
Url : http://uphpu.org/pipermail/uphpu/attachments/20080928/cb8a8600/smime.bin
More information about the UPHPU
mailing list