Link to home
Start Free TrialLog in
Avatar of Chris Michalczuk
Chris MichalczukFlag for United Kingdom of Great Britain and Northern Ireland

asked on

UNION ALL AND GROUP BY

Is it possible to run in the same sql 2000 query a union all and group by statement

what I am doing is creating a view from 4 different tables which hold a siteid in them.
then i want to get a unique list of them but dont really want to do this in 2 views

create view zAllSiteid

select call_siteid as siteid from tbl_calls
union all
select  inventory_siteid as siteid from tbl_inventory
union all
select orders_siteid as siteid from tbl_Orders


then I would do a


select siteid from zAllSite
group by siteid
order by siteid

can i do this in one query?





Avatar of Pratima
Pratima
Flag of India image

try this

Select x.siteid from(
select siteid from zAllSite
group by siteid ) x

order by x.siteid
SOLUTION
Avatar of mayank_joshi
mayank_joshi
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Chris Michalczuk

ASKER

thanks derived table concept is good solution for what i needed to do