--CREATE SOME SAMPLE DATA
CREATE TABLE Casedata
(
NAME VARCHAR(10)
);
INSERT INTO Casedata VALUES ('Test 1');
INSERT INTO Casedata VALUES ('Test 2');
INSERT INTO Casedata VALUES ('None');
-- CASE WHEN IN SQL
SELECT NAME,
CASE
WHEN NAME = 'Test 1' THEN 'The value is 1'
WHEN NAME = 'Test 2' THEN 'The value is 2'
ELSE 'Sorry no Match'
END
FROM Casedata
INSERT INTO HumanResources.departmentcopy(DepartmentID, GroupName, Name, temp)
SELECT DepartmentID,
GroupName,
Name,
CASE WHEN DepartmentID = 1 AND Name = 'Engineering and Research'
THEN 'sucessful' ELSE 'unsucessful' END
FROM HumanResources.department