September 21st, 2012, 02:29 AM
Join Date: Sep 2012
Time spent in forums: 15 m 42 sec
Reputation Power: 0
Combining and adding like results
I have searched all over trying to find away when multiple like records are retreived I need to add together 1 field. My query and results below.
SELECT m.id as 'id', m.name as 'Merchant Name', c.numStamps as 'Num Stampts
on Card', COUNT(c.numStamps) as '# Users with this # Stampts'
FROM Merchants m, Cards c, Stores s
WHERE c.store_id = s.id
AND s.merchant_id = m.id
and c.redeemed = 0
and c.datelaststamp > '2011-07-16 07:00:00'
group by m.id, c.numStamps
order by m.name, c.numStamps
id Merchant Name Stampts UserStampts
391 360 Gourmet Burritos 9 3
391 360 Gourmet Burritos 10 6
I need to combine id and Merchant Name. Stampts does not really matter but I need to add together user stampts. So I need the return to be
391 360 Gourmet Burritos 10 9
Thanks for the help,