Avatar of Chris Michalczuk
Chris Michalczuk
Flag 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?





Microsoft SQL Server 2005

Avatar of undefined
Last Comment
Chris Michalczuk

8/22/2022 - Mon
Pratima

try this

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

order by x.siteid
SOLUTION
mayank_joshi

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
mayank_joshi

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Chris Michalczuk

ASKER
thanks derived table concept is good solution for what i needed to do
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck