Reputation:
I have a table
user_name id status calls
===========================================
apple 21 cars 67
apple 21 bikes 85
apple 21 skates 6
apple 21 pajs 56
orange 34 bikes 9
orange 34 disks 3
orange 34 cars 21
orange 34 pajs 76
I want to add up all the calls for status's
that are cars, bikes and skates only and for each user_name. I have experminted with SUM
but after several hours of late night, earnest attempts its pretty clear to me that this is going to require more than that. Can anyone point me in the right direction please?
Upvotes: 4
Views: 199
Reputation: 12837
select user_name, status, sum(calls) as calls
from table
where status in ('cars', 'bikes', 'skates')
group by user_name, status
Upvotes: 4