Thursday, January 30, 2014

How to implement this in SQL?

marser,


check if this works fr yu:



declare @tab1 table( id1 varchar(2),id2 varchar(2),val int)
declare @tab2 table(id varchar(2))

insert @tab1 select 'A','B',10
insert @tab1 select 'A','C',10

insert @tab2 select 'B'
insert @tab2 select 'C'
insert @tab2 select 'D'

select ISNULL(t1.id1,'A') as id1,t2.id,t1.val
from @tab1 t1
full outer join @tab2 t2 on t1.id2=t2.id





Thanks,

Jay

<If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>


No comments:

Post a Comment