In this SQL tutorial I give you an example of how to use SQL SELECT with CASE WHEN THEN ELSE and for the purpose of this tutorial I will use SQL Server 2012.
Very often you want to perform IF statement in SELECT and replace one value with another. In SQL we cannot use IF in SELECT clause however we can achieve the same result using CASE WHEN THEN ELSE.
In the below example I will use a very simple example where I will divide 7 days into 3 parts: Monday to Wednesday, Thursday to FrIday and Saturday to Sunday.
To get full access to this page
Become a member or Sign in
Membership is just $3.99/month