Query for getting latest date and following ..
hi all,
i have a table TABLE with 10 fields: INT1, DATE1, DATE2, etc etc.
INT1 DATE1 DATE2 ...
1 02-Jan-07 02-Oct-07 ...
2 02-Jan-07 02-Oct-07 ...
1 02-Feb-07 02-Oct-07 ...
1 20-Feb-07 10-Oct-07 ...
The user chooses which INT1 he likes to update(suppose he chooses 1) & then the DATE2 field corresponding to that INT1 is updated whose DATE1 field is latest(like here since user chose INT1=1, & DATE1 field of last row is latest(20-Feb-07), its DATE2 is updated from 10-Oct-07 to some other inputted date value say 15-Oct-07. How do i do that?
I was trying to do something like:
update
(select DATE2, max(DATE1) as dt from TABLE where INT1 = 1 group by DATE1)
set DATE2 = 15-Oct-07;
Can someone help forming a working query?
thank you
|