Advertisement
Guest User

Untitled

a guest
May 29th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.75 KB | None | 0 0
  1. ALTER VIEW cmrpt_overdue_wo
  2. SELECT
  3.     wo.wo_id,
  4.     wo.description,
  5.     wo.date_added,
  6.     wo.date_scheduled,
  7.     wo.date_completed,
  8.     GETDATE() AS Today,
  9.     DATEDIFF(dd, GETDATE(),  wo.date_scheduled) AS Past_Due,
  10.     DATEDIFF(dd, wo.date_scheduled, wo.date_completed) AS Comp_Ontime,
  11.     wo.status,
  12.     ws.id AS Status_ID,
  13.     ws.description AS Status_Desc,
  14.     wt.id AS Type_ID,
  15.     wt.description AS Type_Desc,
  16.     CASE WHEN DATEDIFF(dd, date_scheduled, date_completed) > 0 THEN 1 ELSE 0 END AS OverDue
  17. FROM        
  18.     imtbl_work_order         wo LEFT OUTER JOIN
  19.     imtbl_work_type          wt ON wo.work_order_type = wt.pkey LEFT OUTER JOIN
  20.     imtbl_work_order_status  ws ON wo.status = ws.pkey
  21. WHERE  
  22.     wo.status = 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement