Hello
I have this table which has the following fields:
Table1:
userid, field1, field2, field3, status, date
then I have this other one:
Users:
userid, username
I have a query that selects the following
SELECT
(SELECT username from Users WHERE Users.userid=Table1.userid) as user_name, sum(field1), sum(field2), sum(field3) FROM table WHERE userid=@userid AND date = @date GROUP BY user_name
and another one that goes like
SELECT
(SELECT username from Users WHERE Users.userid=Table1.userid) as user_name, sum(field1), sum(field2), sum(field3) FROM table WHERE userid=@userid AND date = @date AND status = 1 GROUP BY user_name
So basically, the second one has an additional condition (status=1). How can I merge the two so I can get:
username | field1 1st query | field2 1st query | field3 1st query | field1 2nd query | field2 2nd query | field3 2nd query
Thank you in advance
2006-12-06
06:57:16
·
4 answers
·
asked by
Dookie
3