Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

join tables

$
0
0

please help

declare @tab1 table  
( id int, subid int, date2 date)
insert into @tab1 values (1,1,'05/06/2013'), (1,2,'05/03/2013'),(1,3,'05/05/2013'),(1,4,'05/6/2013')
                        ,(2,1,'05/02/2013'), (2,2,'05/07/2013'),(2,3,'05/05/2013'),(2,4,'05/6/2013')

select * from @tab1


declare @tab2 table  
( id int, subid  int, date2 date)
insert into @tab2 values (1,3,'05/4/2013'), (2,3,'05/4/2013')

select * from @tab2

tab1 left join tab2 on subid then would like to tag records whose dates are greater than date in tab2 and also who subid matches like below




Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>