Declare @Sample table (activity_id int, parent_id int, due_date datetime, done_date datetime)
select '168',522,'09-Sep-2016', '11-sep-2016' union all
select '173',522,'12-sep-2016', NULL union all
select '176',522,'14-sep-2016', NULL union all
select '182',522,'15-sep-2016', NULL union all
select '173',522,'16-sep-2016', NULL;
select * from @Sample;
i want to show the next critical activity record, which has the lowest due_date and the done date is null, for that parent_id, for that record i need to show critical=1(true) and remaining records want to show critical=false(0)
critical is a surrogate column with the above case logic. how to put the case logic in select query. little confused.
my final result to appear with following columns last column critical is based on case.
select activity_id, parent_id, due_date, done_date, critical;
thank you very much for the helpful info.