You can do this in a single query without using PIVOT:
SELECT [OnTime] = SUM(CASE WHEN DATEDIFF(MINUTE, T.[Paydate], T.[DelDate]) < 1 THEN 1 ELSE 0 END)
,[Violate] = SUM(CASE WHEN DATEDIFF(MINUTE, T.[Paydate], T.[DelDate]) > 1 THEN 1 ELSE 0 END)
FROM [Transaction_tbl] T
WHERE T.[Locid] = 6
AND T.[Status] = 5
- Vishal
No comments:
Post a Comment