SQL Server, View using multiple select statements -
i've banging head hours, seems simple enough, here goes:
i'd create view using multiple select statements outputs single record-set example:
create view dbo.testdb select x 'first' the_table the_value = 'y' select x 'second' the_table the_value = 'z'
i wanted output following recordset:
column_1 | column_2 'first' 'second'
any appreciated! -thanks.
if want this:
column_1 | column_2 'first' null null 'second'
you can use union suggested in other answers, if want on same row in question:
column_1 | column_2 'first' 'second'
try this:
create view dbo.testdb select dt.first,dt2.second (select x 'first',row_number() over(order x) rownumber the_table the_value = 'y' ) dt left outer join (select x 'second',row_number() over(order x) rownumber the_table the_value = 'z' ) dt2 on dt.rownumber=dt2.rownumber go
i'm not sure how join tables, no info pks or how join them given.
Comments
Post a Comment