I have a table like the following
User Item
A 1
A 1
A 1
B 1
B 2
C 2
C 2
A 2
I’m trying to run a query so I can get an output such as
User Item Count
A 1 3
B 1 1
B 2 1
A 2 1
C 2 2
I’ve tried the following query, however I’m not getting the output right.
select f.item,f.uid, COUNT(f.uid) as count
from fresh f,
product p
where f.locationid = p.iid
group by f.locationid, f.uid
order by f.uid desc;
Can anyone point out how I write a query to get the required output? I could write it up in python / ruby but I think it’ll take a lot longer to run! 🙁
1 Answer