lesleycampbell
Technical User
I'm using SQL Server 2008. I'm trying to update a temp table with values dependent on the max occurrence of another column. Please be patient with me in my explanation. Thank you!
Temp Table - #APPTRACKER
Columns - Reason, Remarks
Table - History
Columns - HistoryID, Date, Comment, Event
In the previous UPDATE the 'Reason' column only pulls data when the 'Event' is in ('a','b','c').
In this UPDATE, if the 'Reason' column is null, I want to pull the data from the 'Comment' column from the MAX date entry when the 'Event' is in 'RCT'.
If the 'Reason' column is not null, I want to pull the data from the 'Comment' column of the same history ID from the previous UPDATE.
If there is no historyID with the event of 'a','b','c','d', or 'RCT', then I want to leave the field blank.
Temp Table - #APPTRACKER
Columns - Reason, Remarks
Table - History
Columns - HistoryID, Date, Comment, Event
In the previous UPDATE the 'Reason' column only pulls data when the 'Event' is in ('a','b','c').
In this UPDATE, if the 'Reason' column is null, I want to pull the data from the 'Comment' column from the MAX date entry when the 'Event' is in 'RCT'.
If the 'Reason' column is not null, I want to pull the data from the 'Comment' column of the same history ID from the previous UPDATE.
If there is no historyID with the event of 'a','b','c','d', or 'RCT', then I want to leave the field blank.