SQL: custom names of columns when using IIF (excel quering access database)

R

riso

Hi all,

I am creating in Excel (via data/import new external data/new
database query) a query from MS Access database using statement IIF,
but excel ignore my column names (... AS 'custom name'...) and use
artificial ones (e.g. expr1002,expr1003 etc)

My code looks like:

SELECT table1.persID AS 'ID personal',
table1.surname+' '+table1.name AS 'Full name' ,
IIF ((select top 1 tbl2.order from tbl2 tbl2
where table1.year_ID = tbl2.year_ID and
tbl2.PID = table1.PID and
tbl2.order is not null
)is null
, null
, (select top 1 tbl2.order from tbl2 tbl2
where table1.year_ID = tbl2.year_ID and
tbl2.PID = table1.PID and
tbl2.order is not null)
) as 'Order'
FROM table1 table1

I want to have table with columns 'ID personal', 'Full name' and
'Order', but I recieve fine data with funny column names. What is
wrong?

Thank you for any hint.

riso
 
M

merjet

Not knowing your tables, I can't help much. But one thing -- use
brackets rather than quotes to enclose field names with spaces, e.g.
AS [ID personal]

Hth,
Merjet
 

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

Top