If this is just something you want to view, adhoc, then the below will work, as it does not set anything in the tables:
This code will add a column with the status for every line:
SELECT
[Customer ID],
Product,
Status,
CASE
WHEN
Status = 'Paying'
THEN
'Active'
WHEN
Status = 'Paying-Installment'
THEN
'Active'
ELSE
'Inactive'
END AS Active
FROM customerTable
This code will add a column with the status but only show the customer and the status:
SELECT DISTINCT
[Customer ID],
CASE
WHEN
Status = 'Paying'
THEN
'Active'
WHEN
Status = 'Paying-Installment'
THEN
'Active'
ELSE
'Inactive'
END AS Active
FROM customerTable
The difference between the two is what columns are shown, and the DISTINCT command.
* Be the first to Make Comment