I have two tables
Table 1
ID CompanyName
1 A
2 B
Table 2 <--this table only record the change in RatingName Value
ID RatingName Value TimeStamp
1 T1 5 10/11/2006
1 T2 5 10/11/2006
2 T1 5 10/11/2006
2 T2 5 10/11/2006
'default value above and change is below
1 T2 6 10/12/2006
2 T1 7 10/12/2006
2 T2 7 10/12/2006
1 T2 8 10/13/2006
I want to be able to return the change value if exist if not I return the old value from previous date or previous latest date
result
ID| T1| T2| T1time| T2time <--need max date the lastest
1| 5| 8| 10/11/2006| 10/13/2006<--since only T2 is updated
2| 7| 7| 10/12/2006| 10/12/2006<--since both T1 and T2 changed
Any suggestion on creating a view and select from it or an sql statement that give me the result ? thanks
Table 1
ID CompanyName
1 A
2 B
Table 2 <--this table only record the change in RatingName Value
ID RatingName Value TimeStamp
1 T1 5 10/11/2006
1 T2 5 10/11/2006
2 T1 5 10/11/2006
2 T2 5 10/11/2006
'default value above and change is below
1 T2 6 10/12/2006
2 T1 7 10/12/2006
2 T2 7 10/12/2006
1 T2 8 10/13/2006
I want to be able to return the change value if exist if not I return the old value from previous date or previous latest date
result
ID| T1| T2| T1time| T2time <--need max date the lastest
1| 5| 8| 10/11/2006| 10/13/2006<--since only T2 is updated
2| 7| 7| 10/12/2006| 10/12/2006<--since both T1 and T2 changed
Any suggestion on creating a view and select from it or an sql statement that give me the result ? thanks