Union Query; Add a Field

R

ryguy7272

I am trying to create a UnionQuery, which is almost working the way I want it
to, but not quite. I want to put a field named ‘Year’ right at the end. My
SQL is below:

SELECT *, "2008" FROM [RMReport];
UNION SELECT *, "2008" FROM [Report2008];

I am getting 2008 one field before the last field and the name of the filed
is ‘Expr1000’. How can I get the Year right at the end, and also name the
Filed as ‘Year’?

Thanks so much,
Ryan---
 
B

BobT

Make your Union query part of an inline query, like this:

Select *
From
(
Select *, "2008" As "Year"
From [RMReport]
UNION
Select *, "2008" As "Year"
From [Report2008]
)

You will then be able to switch from SQL view to Design view (with the Query
by Example grid) and order the columns however you want.
 
R

ryguy7272

Wow!! That's pretty cool!! I've never seen that before.
Thanks BobT!!

Ryan--

--
RyGuy


BobT said:
Make your Union query part of an inline query, like this:

Select *
From
(
Select *, "2008" As "Year"
From [RMReport]
UNION
Select *, "2008" As "Year"
From [Report2008]
)

You will then be able to switch from SQL view to Design view (with the Query
by Example grid) and order the columns however you want.

ryguy7272 said:
I am trying to create a UnionQuery, which is almost working the way I want it
to, but not quite. I want to put a field named ‘Year’ right at the end. My
SQL is below:

SELECT *, "2008" FROM [RMReport];
UNION SELECT *, "2008" FROM [Report2008];

I am getting 2008 one field before the last field and the name of the filed
is ‘Expr1000’. How can I get the Year right at the end, and also name the
Filed as ‘Year’?

Thanks so much,
Ryan---
 

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