SELECT
ScheduledStartDate, ActualStartDate, ScheduledEndDate, ActualEndDate,
CASE
(WHEN ActualStartDate > ScheduledStartDate THEN 'started late'
WHEN ActualStartDate < ScheduledStartDate THEN 'started early'
WHEN ScheduledStartDate = ActualStartDate then 'started on time'
END AS startDescription )
ELSE
CASE
(WHEN ActualEndDate < ScheduledEndDate THEN 'finished late'
WHEN ActualEndDate > ScheduledEndDate THEN 'finished early'
WHEN ActualEndDate = ScheduledEndDate THEN 'finished on time'
END AS endDescription )
FROM
[Production].[WorkOrderRouting];
Я сделал 4 столбца и хочу добавить 2 новых столбца, сделанных с помощью оператора case.