Sub Selects
Posted: Mon Nov 08, 2004 9:30 am
Boys and Squirrels,
I am having trouble getting the desired results from my sub select query
I am trying to output the user name and the total counts from each category using the following query
The main problem I am seeing, is that it is not outputing the proper counts for the same id from the two queries.. it kinda of mixes them...
Any suggestions?
Regards,
I am having trouble getting the desired results from my sub select query
I am trying to output the user name and the total counts from each category using the following query
Code: Select all
select distinct a.name,a.count1,b.count2 from gifts, (select count(g.gid) as count1,r.name from gifts g,recipients r where g.uid=1 and g.category=2 and g.rid = r.rid group by r.name)a, (select count(g.gid) as count2,r.name from gifts g,recipients r where g.uid=1 and g.category=1 and g.rid = r.rid group by r.name)b group by a.nameAny suggestions?
Regards,