Union Query - Group & Sum

  • Thread starter Thread starter Gavelle
  • Start date Start date
G

Gavelle

Below is my union query. The problem i'm having is that it omits two fields
from the three base queries (Num) and (Den). I feel like i'm just on the
edge of figuring this out but every combination i try won't run. How can i
add the Num & Den fields to my union query result?

SELECT [UnitDesc], [Sort Month]
FROM [DirectObserv Compliant Rate BD - By Unit by month]
UNION
SELECT [UnitDesc], [Sort Month]
FROM [DirectObserv Compliant Rate DC - By Unit by month]
UNION SELECT [UnitDesc], [Sort Month]
FROM [DirectObserv Compliant Rate LF - By Unit by month]
GROUP BY [UnitDesc],[Sort Month];
 
SELECT [UnitDesc], [Sort Month], [Num], [Den]
FROM [DirectObserv Compliant Rate BD - By Unit by month]
UNION
SELECT [UnitDesc], [Sort Month], [Num], [Den]
FROM [DirectObserv Compliant Rate DC - By Unit by month]
UNION
SELECT [UnitDesc], [Sort Month], [Num], [Den]
FROM [DirectObserv Compliant Rate LF - By Unit by month]
GROUP BY [UnitDesc],[Sort Month];
 
Back
Top