sql server 2008 - How to join two tables to select all data with and without the condition in MsSQL -
i have 2 tables.
table_sale
s_date
s_store
s_item_id
s_qty
table_return
r_date
r_store
r_item_id
r_qty
imagine table_sale have 1000 row , table_return have 250 rows.i want
cindition.
(s_date=r_date , s_store=r_store , s_item_id=r_item_id)
think there 150 rows match condition. there 850 rows table_sale , 100 row in table_return not matching condition. want 150+100+850 data in 1 table. how can make join sir.?please me.
you should use full outer join. this...
select * table_sale full outer join table_return b on a.s_date = b.r_date , a.s_store = b.r_store , a.s_item_id = b.r_item_id
Comments
Post a Comment