title: Calculate difference between two columns sql
body: <p>in my SQL Query i am Calculating column values by using <code>CASE WHEN THEN ELSE END</code> Condition.
  Now i want to find difference between computed column and normal column</p>
  
  <p>My Query</p>
  
  <pre><code>SELECT  T.Ticket [Ticket],
          TT.TicketType [Ticket Type],
          T.Dependency [Dependency],
          CASE 
                  WHEN (
                          SELECT  TOP 1 f1.UpdatedOn
                          FROM    TicketTypeFollowUp AS f1
                          WHERE   f1.UpdatedOn &lt; T.UpdatedOn
                                  AND f1.Ticket = 61423
                          ORDER   BY f1.UpdatedOn DESC
                      ) IS NULL
                  THEN Ticket.TicketRaisedOn
                  ELSE (
                          SELECT  TOP 1 f1.UpdatedOn
                          FROM    TicketTypeFollowUp AS f1
                          WHERE   f1.UpdatedOn &lt; T.UpdatedOn
                                  AND f1.Ticket = 61423
                          ORDER   BY f1.UpdatedOn DESC
                      )
                  END [Start Date],
          T.UpdatedOn [End Date],
          L.EmpName [Updated By]
  FROM    dbo.TicketTypeFollowUp T
          LEFT JOIN dbo.Ticket
                  ON T.Ticket = Ticket.Code
          LEFT JOIN dbo.TicketType TT
                  ON T.TicketType = TT.Code
          LEFT JOIN LoginUser L
                  ON T.UpdatedBy = L.Code
  WHERE Ticket = 61423
  </code></pre>
  
  <p>Query Result</p>
  
  <pre><code>Ticket  Type    Dependency  Start Date              End Date                Updated By
  61423   FLM     AGS         2013-01-22 15:50:08.757 2013-01-22 18:35:50.893 Kedar S
  </code></pre>
  
  <p><strong>I want one more column which displays <code>End Time - Start Time</code></strong> I have used <code>CASE</code> hence i am unable to compute difference. </p>
  
  <p>Database is SQL SERVER 2008</p>