the way to create a view from 2 or more tables

hi you expertss
how achive a view from 2 or more tables
tsm

create view tubos as
select top 100 percent  min(size_1) as min,max(size_1) as max, long_desc2+' '+long_desc1 as descripcion,face,cedula_lb from pipe_pipe_spec group by long_desc2,long_Desc1,face,cedula_lb order by long_Desc2
select top 100 percent  min(size_1) as min,max(size_1) as max, short_desc+' '+long_desc1 as descripcion,face,cedula_lb from pipe_pvlv_spec group by short_desc,long_Desc1,face,cedula_lb order by short_desc
ErnestoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
You mean you want the result of both queries as a single result? If so, use UNION:
https://msdn.microsoft.com/en-us/library/ms180026.aspx

select top 100 percent  min(size_1) as min,max(size_1) as max, long_desc2+' '+long_desc1 as descripcion,face,cedula_lb from pipe_pipe_spec group by long_desc2,long_Desc1,face,cedula_lb order by long_Desc2
UNION
select top 100 percent  min(size_1) as min,max(size_1) as max, short_desc+' '+long_desc1 as descripcion,face,cedula_lb from pipe_pvlv_spec group by short_desc,long_Desc1,face,cedula_lb order by short_desc

Just make sure that all the queries return the same number of columns.
ErnestoAuthor Commented:
Oh man
I dont want the union, i want to put in a table the 2 querys results
tsm you expert
regards
PWinterCommented:
Try this:
create view tubos as
select min(size_1) as min
	, max(size_1) as max
	, long_desc2 + ' ' + long_desc1 as descripcion
	, face as face
	, cedula_lb as cedula_lb 
from pipe_pipe_spec 
group by long_desc2
	,long_Desc1
	,face
	,cedula_lb
UNION ALL
select min(size_1)
	, max(size_1)
	, short_desc + ' ' + long_desc1
	, face
	, cedula_lb 
from pipe_pvlv_spec 
group by short_desc
	, long_Desc1
	, face
	, cedula_lb

Open in new window


Good luck.
PW

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.