SQL Server Express Edition: Generate conditional columns in SQL Server using Case statements

Platform:SQL Server Express Edition
Task:Generate conditional columns in SQL Server using Case statements
Discussion:
From http://www.sqlhacks.com/Retrieve/ConditionalColumns
Example:
-- from http://www.sqlhacks.com/Retrieve/ConditionalColumns
SELECT empno, SUM(emptime) AS "Hours Worked",
CASE
WHEN SUM(emptime) < 4 THEN 'Beach bum'
WHEN SUM(emptime) = 4 THEN 'OK'
WHEN SUM(emptime) > 4 THEN 'Hard worker'
END AS 'Evaluation'
FROM emp_work
GROUP BY empno;

Back to Index