MattSmithProg
Programmer
Hi All,
I have probably a really easy question but I can't seem to nut it out.
I have a Union query like this.
SELECT UserId, Site, NAT, Count(NAT) As Total
FROM PTAPP_ACR_MAIN
WHERE Site = 'HOB'
GROUP BY 1, 2, 3
UNION ALL
(SELECT UserId, Site, NAT, Count(Nat) As Total
FROM PTAPP_ACR_Inactive
WHERE Site = 'HOB'
Group By 1, 2, 3)
ORDER BY 1, 2, 3
;
However I want to group the results from the two tables together. Ie I get the same UserId, Site, Nat twice in the results but each set is the total from each table.
I would like to use a group by on the whole result query but am not sure how.
Any help would be greatly appreciated.
Thanks
Matt Smith No two nulls are the same
I have probably a really easy question but I can't seem to nut it out.
I have a Union query like this.
SELECT UserId, Site, NAT, Count(NAT) As Total
FROM PTAPP_ACR_MAIN
WHERE Site = 'HOB'
GROUP BY 1, 2, 3
UNION ALL
(SELECT UserId, Site, NAT, Count(Nat) As Total
FROM PTAPP_ACR_Inactive
WHERE Site = 'HOB'
Group By 1, 2, 3)
ORDER BY 1, 2, 3
;
However I want to group the results from the two tables together. Ie I get the same UserId, Site, Nat twice in the results but each set is the total from each table.
I would like to use a group by on the whole result query but am not sure how.
Any help would be greatly appreciated.
Thanks
Matt Smith No two nulls are the same