L
Liv
I am current using a Union Query like this:
SELECT Region, Count([Region]) AS Count, Sum([Total Value]) AS Sum,
Avg([DateApproved]-[DateReceived]) AS [Avg], "A" AS MyTable
FROM [tblA]
GROUP BY Region
UNION ALL SELECT Region, Count([Date]) AS Count, Sum([DollarAmount]) AS Sum,
Avg([AnotherDate]-[Date]) AS [Avg], "B1" AS MyTable
FROM [tblB]
GROUP BY Region
UNION ALL SELECT Region, Count([AnotherDate]) AS Count, Sum([DollarAmount])
AS Sum, Avg([OtherDate]-[AnotherDate]) AS [Avg], "B2" AS MyTable
FROM [tblB]
GROUP BY Region;
Which returns something like this:
Region Count Sum Avg MyTable
NCAL 16 552 3.75 A
SCAL 28 915 A
NCAL 322 5555 1.39 B1
SCAL 378 516 31 B1
NCAL 2 944 B2
SCAL 130 7457 1.38 B2
I would like to break this info out by date returning something like this:
Region YTDCount... Jan2009Count... Dec2009Sum YTDAvgMyTable
NCAL 16 3 6107 A
SCAL 28 2 11000 A
NCAL 322 29 5547 B1
SCAL 378 28 62009 B1
NCAL 2 0 B2
SCAL 130 7 5803 B2
SELECT Region, Count([Region]) AS Count, Sum([Total Value]) AS Sum,
Avg([DateApproved]-[DateReceived]) AS [Avg], "A" AS MyTable
FROM [tblA]
GROUP BY Region
UNION ALL SELECT Region, Count([Date]) AS Count, Sum([DollarAmount]) AS Sum,
Avg([AnotherDate]-[Date]) AS [Avg], "B1" AS MyTable
FROM [tblB]
GROUP BY Region
UNION ALL SELECT Region, Count([AnotherDate]) AS Count, Sum([DollarAmount])
AS Sum, Avg([OtherDate]-[AnotherDate]) AS [Avg], "B2" AS MyTable
FROM [tblB]
GROUP BY Region;
Which returns something like this:
Region Count Sum Avg MyTable
NCAL 16 552 3.75 A
SCAL 28 915 A
NCAL 322 5555 1.39 B1
SCAL 378 516 31 B1
NCAL 2 944 B2
SCAL 130 7457 1.38 B2
I would like to break this info out by date returning something like this:
Region YTDCount... Jan2009Count... Dec2009Sum YTDAvgMyTable
NCAL 16 3 6107 A
SCAL 28 2 11000 A
NCAL 322 29 5547 B1
SCAL 378 28 62009 B1
NCAL 2 0 B2
SCAL 130 7 5803 B2