|
IK1972
Starting Member
41 Posts |
Posted - 03/13/2013 : 14:56:48
|
drop table #temp Create table #temp(TranID int, TaskID int, TaskName varchar(255), TaskStatus varchar(25))
insert into #temp values (1,1,'A1','Created'), (1,2,'A2','Created'), (1,3,'A3','Created'), (1,4,'A4','Created'), (1,5,'A5','Created'), (2,6,'A1','Completed'), (2,7,'A2','Created'), (2,8,'A3','Created'), (2,9,'A4','Created'), (2,10,'A5','Created'), (3,11,'A1','Completed'), (3,12,'A2','Completed'), (3,13,'A3','Completed'), (3,14,'A4','Created'), (3,15,'A5','Created'), (4,16,'A1','Completed'), (4,17,'A2','Completed'), (4,18,'A3','Completed'), (4,19,'A4','Completed'), (4,20,'A5','Created'), (5,21,'A1','Created'), (5,22,'A2','Created'), (5,23,'A3','Completed'), (5,24,'A4','Created'), (5,25,'A5','Created') Basically for every TranID we have 5 Tasks.
My Requirement is for any TranID check the first task which is created and then cancel all others if its not completed.
For TranID 1 Task ‘A1’ is Created so we can cancel all others means (A2 to A5)
For TranID 2 First Created Task is A2 so we can cancel (A3 to A5)
For TranID 3 First Created Task is A4 so we can cancel only (A5)
For TranID 4 First Created Task is A5 and after that we don’t have any task so no update
For TranID 5 Task A1 is Created and Task A3 is completed so we can cancel Task (A2,A4,A5)
Thanks
|
|