Excel MS query removes 'as' from select part of sql

I have built a sql with several left joins that I use in MS Query in Excel:
select tb1.uttaksnr as 'Ordrenr', tb1.Info as 'Importer', tb4.beskrivelse as 'Dest', tb1.bl_awb as 'Transit', tb1.avgangsdato as 'Departure origin', '' AS 'Date',  '' AS 'Del Oslo', tb1.LeveringsdatoFra as 'DelDate', tb1.bl_awb as 'Awb', tb1.flight, 'ST423' as 'Pakkeri', tb2.navn as 'Transportor', tb3.navn as 'Kunde'
from  W729SalgsHode tb1 
left join Wv007Transportor  tb2 on  (tb1.Klientnr=tb2.Klientnr and tb1.transportornr=tb2.transportornr)
left join RW002kunde tb3 on (tb1.Klientnr = tb3.Klientnr and tb1.kundenr=tb3.kundenr)
left join W003levSted tb4 on (tb1.Klientnr = tb4.Klientnr and tb1.levstedanr=tb4.levstedanr)
where (tb1.kundenr=10383 Or tb1.kundenr=10555 Or tb1.kundenr=10596 Or tb1.kundenr=10597 Or tb1.kundenr=10598 Or tb1.kundenr=10407 Or tb1.kundenr=10499) And tb1.avgangsdato >= Today()

Open in new window


The sql workes when I paste it in MS Query, but it removes all the 'as' parts in the select and ends up with this:
select tb1.uttaksnr , tb1.Info , tb4.beskrivelse , tb1.bl_awb , tb1.avgangsdato , '' ,  '' , tb1.LeveringsdatoFra , tb1.bl_awb , tb1.flight, 'ST423' , tb2.navn , tb3.navn 
from  W729SalgsHode tb1 
left join Wv007Transportor  tb2 on  (tb1.Klientnr=tb2.Klientnr and tb1.transportornr=tb2.transportornr)
left join RW002kunde tb3 on (tb1.Klientnr = tb3.Klientnr and tb1.kundenr=tb3.kundenr)
left join W003levSted tb4 on (tb1.Klientnr = tb4.Klientnr and tb1.levstedanr=tb4.levstedanr)
where (tb1.kundenr=10383 Or tb1.kundenr=10555 Or tb1.kundenr=10596 Or tb1.kundenr=10597 Or tb1.kundenr=10598 Or tb1.kundenr=10407 Or tb1.kundenr=10499) And tb1.avgangsdato >= Today()

Open in new window


When I simplify sql and remove all the joins the 'as' part of sql stays put. Is it not possible to us 'as' in sql with joins or do I have to use another syntax to make this happen?
hallpettAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Enclosing the alias in single quotes is non-standard, and might be the reason. So first test is to remove the single quotes.
You can enclose the alias in double quotes.
You can try if using    alias = cvolumn   makes a difference.

Whatsoever, the behaviour should not be different if using a JOIN from without.
hallpettAuthor Commented:
I have tried these three ways:
select tb1.uttaksnr as 'Ordrenr',
select tb1.uttaksnr as Ordrenr,
select tb1.uttaksnr as "Ordrenr",

Open in new window


The result is always:
select tb1.uttaksnr ,

The behavior are definitely different when using join in my case. When I the strip the sql and have only one table in the from part there is no problem with the 'as'.

What to you mean saying: "try using alias = cvolumn"?
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
select tb1.uttaksnr as Ordrenr,
would be
   select OrdreNr = tb1.uttaksnr,

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hallpettAuthor Commented:
This workes: select OrdreNr = tb1.uttaksnr
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.