Create SQL Server simple CASE expression



The following shows the syntax of the simple CASE expression

SELECT
CASE productStatus
WHEN 1 THEN 'Pending'
WHEN 2 THEN 'Processing'
WHEN 3 THEN 'Rejected'
WHEN 4 THEN 'Completed'
END AS productStatus,
COUNT(id) count
FROM
products
WHERE
YEAR(createdDatetime) = 2018
GROUP BY
productStatus;

0 Comment's

Comment Form

Submit Comment