Union Query; Add a Field

  • Thread starter Thread starter ryguy7272
  • Start date Start date
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---
 
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.
 
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---
 
Back
Top