Reputation: 17
I had 2 queries that were pulling in similar types of data so I used a UNION ALL query to join them. However, now when I go to pull in the data from Access on my Excel workbook the query doesn't show up. How do I make a union query show up in my Excel??
For reference:
SELECT yyy.Sold_Date, yyy.Sold_Year, yyy.Sold_Month, yyy.Sold_Week, yyy.Pricing_System, yyy.Deal_Orientation, Count(yyy.Customer_Name) AS CountOfCustomer_Name, Sum(yyy.MeterCount) AS SumOfMeterCount, Avg(yyy.Term) AS AvgOfTerm, Sum(yyy.AMWh) AS SumOfAMWh, Sum(yyy.TMWh) AS SumOfTMWh, yyy.Flow_Start, yyy.Flow_End, Sum(yyy.Unit_Margin) AS SumOfUnit_Margin, Sum(yyy.Term_GM) AS SumOfTerm_Margin, 'yyy' AS D2DType
FROM yyy
WHERE yyy.Pricing_System = 'm'
GROUP BY yyy.Sold_Date, yyy.Sold_Year, yyy.Sold_Month, yyy.Sold_Week, yyy.Pricing_System, yyy.Deal_Orientation, yyy.Flow_Start, yyy.Flow_End
UNION ALL
SELECT xxx.Sold_Date, xxx.Sold_Year, xxx.Sold_Month, xxx.Sold_Week, xxx.Pricing_System, xxx.Deal_Orientation, Count(xxx.Business_Name) AS CountOfCustomer_Name, Sum(xxx.MeterCount) AS SumOfMeterCount, Avg(xxx.Term) AS AvgOfTerm, Sum(xxx.AMWh) AS SumOfAMWh, Sum(xxx.TMWh) AS SumOfTMWh, xxx.Flow_Start, xxx.Flow_End, Sum(xxx.Unit_Margin) AS SumOfUnit_Margin, Sum(xxx.Term_Margin) AS SumOfTerm_Margin, 'xxx' AS D2DType
FROM xxx
WHERE xxx.Pricing_System = 'm'
GROUP BY xxx.Sold_Date, xxx.Sold_Year, xxx.Sold_Month, xxx.Sold_Week, xxx.Pricing_System, xxx.Deal_Orientation, xxx.Flow_Start, xxx.Flow_End, 'D2DType' ;
Upvotes: 0
Views: 2336
Reputation: 31
Make another Select query from Union Query. Select all the columns, this new query will be visible in Excel Get Data.
Upvotes: 3
Reputation: 388
This has worked for me in similar situations. Use the "From Other Sources" option to get external data shown here:
Then choose "From Microsoft Query". In the Choose Data Source box scroll through the options and select MS Access Database. Navigate to the location of the Access database and select in the left pane. The "Query Wizard" window should pop up and show the available queries and tables that you can connect to. The union query should be available here. Step through the subsequent options and it will set up a connection like usual. I'm not sure why it doesn't show the Union Queries in the "From Access" options.
Upvotes: 0