Using SQL Server 2000
table 1:
ID LastDate
001 20090101
003 20090501
004 20090302
...
table2:
ID Date Value
001 20090101 100
001 20090102 200
001 20090103 200
002 20090101 350
002 20090302 500
003 20090501 200
003 20090502 250
004 20090302 400
...
From the table2 I want to Select id and date, date should display from next date onwards from table1.
Query like:
Select * from table2 where date > table1.last on table1.id = table2.id
Expected Output:
ID Date Value
001 20090102 200
001 20090103 200
002 20090101 350
002 20090302 500
003 20090502 250
...
From the above output,
id 001 is displaying from the next date of table1.lastdate
id 002 is displaying the same date because 002 is not in table1
id 003 is displaying from the next date of table1.lastdate
id 004 is not displaying because the same date is available on table1.lastdate
I want to make a query for the above condition.
Try it:
Edited: