javierpdx
asked on
TSQL joins
I'm trying to setup this query so that all records form the Registration table show and when G.MYID does not = R.MYID, then the value would be a zero.
SELECT COUNT(G.GuestRegID) AS GCOUNT, R.MYID
FROM dbo.Guest AS G Full OUTER JOIN
dbo.Registration AS R ON G.MYID= R.MYID
WHERE (G.IsActive = 1)
GROUP BY G.MYID, R.MYID
How could I modify this query to show all records in R, and if G.MYID does not equal R.MYID then return a zero?
I'm using SQL Server 2012.
Thanks.
SELECT COUNT(G.GuestRegID) AS GCOUNT, R.MYID
FROM dbo.Guest AS G Full OUTER JOIN
dbo.Registration AS R ON G.MYID= R.MYID
WHERE (G.IsActive = 1)
GROUP BY G.MYID, R.MYID
How could I modify this query to show all records in R, and if G.MYID does not equal R.MYID then return a zero?
I'm using SQL Server 2012.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. I was struggling with this.
Open in new window