MS Query Help

gilligan73

New Member
Joined
Jul 16, 2014
Messages
8
Hello all,

I seem to be having a problem with MS Query, as I am used to MS SQL database but am not allowed to use it. I am trying to join two queries, based on the country name being the same. I actually got it work once but I can't seem to see what I am doing wrong.

I am using Excel 2010:

The sheet names are theData and ConcreteData:

select a.CountryName, Sum(a.FinalAmount) as Total
from
(SELECT [TheData$].CountryName as Country, [TheData$].FinalAmount as amt
FROM [TheData$] [TheData$]
union all
SELECT [ConcreteData$].Country as Country, [ConcreteData$].TotalKV as amt
FROM [ConcreteData$] [ConcreteData$]
) a
GROUP BY a.Country

I get "Could not add the table 'SELECT'" as an error message.

Many thanks in advance,
Dave
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
I only have Excel 2007 so for me this will work. You can see if it works the same in 2010:

select country, sum(amt) as Total
from
(SELECT `ConcreteData$`.Country as [country] , `ConcreteData$`.Totalkv as [amt]
FROM `M:\Excel\queryMs.xlsx`.`ConcreteData$` `ConcreteData$`
union all
SELECT `theData$`.Countryname as [country] , `theData$`.finalamount as [amt]
FROM `M:\Excel\queryMs.xlsx`.`theData$` `theData$`)
Group by country;

Path will need changing.
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,687
Members
449,117
Latest member
Aaagu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top