cross tab

  • Thread starter Thread starter subs
  • Start date Start date
S

subs

how to join the following two cross tab queries by SQL? pl s help




TRANSFORM Avg([current year].SumOfPAID_AMT) AS AvgOfSumOfPAID_AMT
SELECT [current year].OCITY
FROM [current year]
GROUP BY [current year].OCITY
PIVOT theYear

TRANSFORM Avg([current year].SumOfTRANSPORT_AMT) AS
AvgOfSumOfTRANSPORT_AMT
SELECT [current year].OCITY
FROM [current year]
GROUP BY [current year].OCITY
PIVOT theYear;
 
Create a query like below:

SELECT [current year].OCITY ,
"PAID_AMT" as Amounts,
Avg([current year].SumOfPAID_AMT) AS AvgOfSumOfPAID_AMT
FROM [current year]
GROUP BY [current year].OCITY, AmountType
UNION ALL
SELECT [current year].OCITY ,
"PAID_AMT" As AmountType,
Avg([current year].SumOfTRANSPORT_AMT) AS AvgOfSumOfTRANSPORT_AMT
FROM [current year]
GROUP BY [current year].OCITY, AmountType;

Then use the above as the basis for a crosstab query. You may not need the
AmountType lines.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

crosstab queries 1
complex sorting query 3
sql help req 1
Query needed 3
Query by Month and Year (Repost) 2
Query By Month and Year - Access 2007 2
Query Help 2
Year to Date subquery 3

Back
Top