SQL Server, View using multiple select statements

Posted by phil on Stack Overflow See other posts from Stack Overflow or by phil
Published on 2010-04-28T19:56:47Z Indexed on 2010/04/28 20:07 UTC
Read the original article Hit count: 153

Filed under:
|
|
|

I've banging my head for hours, it seems simple enough, but here goes:

I'd like to create a view using multiple select statements that outputs a Single record-set Example:

CREATE VIEW dbo.TestDB
AS
SELECT     X AS 'First'
FROM       The_Table
WHERE     The_Value = 'y'

SELECT     X AS 'Second'
FROM       The_Table
WHERE     The_Value = 'z'

i wanted to output the following recordset:

Column_1 | Column_2
'First'    'Second'

any help would be greatly appreciated! -Thanks.

© Stack Overflow or respective owner

Related posts about sql

Related posts about tsql