February 26, 2003 at 10:18 am
Just a quick question in regards to using UNION ALL: Is there anyway I can use one where claus to effect every select in a UNION ALL. LIke this
Select * from cub_elec_hist
UNION ALL
Select * from msh_elec_hist
WHERE TYPE = 'RES' and mtyr_period = '12/1/2002'
or does it have to be like this.
Select * from cub_elec_hist
WHERE TYPE = 'RES' and mtyr_period = '12/1/2002'
UNION ALL
Select * from msh_elec_hist
WHERE TYPE = 'RES' and mtyr_period = '12/1/2002'
February 26, 2003 at 10:26 am
Just wrap the union in another select:
select * from
(
select * from a
union all
select * from b
)
where whatever=something
Andy
February 26, 2003 at 10:42 am
I tried this and I got the following error:
Incorrect syntax near the keyword 'WHERE'.
Select * from
(
Select * from cub_elec_hist
UNION ALL
Select * from msh_elec_hist
)
WHERE TYPE = 'RES' and mtyr_period = '12/1/2002'
February 26, 2003 at 10:56 am
Dont have access to a server, so it's off the cuff! Try adding an alias after the close paren.
Andy
February 26, 2003 at 11:02 am
Works Great!
Select * from
(
Select * from cub_elec_hist
UNION ALL
Select * from msh_elec_hist
) a
WHERE TYPE = 'RES' and mtyr_period = '12/1/2002'
Thanks Andy
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply