How Can I use UPDATE after a SELECT subquery?

I am using SSMS where I am trying to get the task which are pending and if the ModifiedDate has exceeded the time limit of five days limit then I want to update the status to 0 and set the ResolutionDate to Null. I know the syntax of Update but I am not sure how to use it after a Select subquery. This is what I have so far

  Select Task_Id,
         Task_number,
         LastModifiedDate,
         ResolutionDate,
         Status
  From Tablexxxx  
  where Status = 1
  AND ResolutionDate IS NOT NULL
    (Select 
        ( Case 
              When ModifiedDate <= dbo.EpochToDate(ModifiedDate) Then ModifiedDate
              Else dbo.EpochToDate(ModifiedDate)
              End)
      From Tablexxxx);

I dont know how to use this update with the Select subquery

Update table 
Set Status = 0,  ResolutionDate = null
Where ModifiedDate = dbo.EpochToDate(ModifiedDate);

1 answer

  • answered 2018-11-08 06:24 Sarvesh Bandekar

    What i understand from your question, by that this is the correct solution, please check and confirm if i am wrong with my understanding about your question

    update #table_name set [status]=0, ResolutionDate=null where DATEDIFF(dd,ModifiedDate,getdate())>=5