Case When_ SQL
1.SELECT OrderID,Quality,
CASE
WHEN Quality>30 THEN 'The quantity is greater than 30'
WHEN QUality =30 THEN 'The quatity is 30;
ELSE 'The quantity is under30;
END AS QualityText
FROM OrderDetails;
2.Oder by City-》City is NULL->Country
SELECT CUstomerName,City,Country
FROM Customers
ORDER BY
(CASE
WHEN City is NULL THEN COuntry
ELSE CITY
END);
3.CREATE PROCEDURE SelectAllCustomers
AS
SELECT * FROM Customers
GO;
4.EXEC SlectAllCustomers;