I have multiple conditions to meet in a case I would like to Know if I can use > < instead of defining every case
In this case when the credit rating is smaller then 3 then, the word "NO TRADE" will be inserted and larger then 3, smaller then 5 would be "POOR", and so on and so on
SELECT ClientId,
FirstName,
LastName,
Gender,
DateOfBirth,
CreditRating,
CASE CreditRating
WHEN 0 THEN 'NO TRADE'
WHEN 1 THEN 'NO TRADE'
WHEN 2 THEN 'NO TRADE'
WHEN 3 THEN 'POOR'
WHEN 4 THEN 'POOR'
WHEN 5 THEN 'AVARAGE'
WHEN 6 THEN 'AVARAGE'
WHEN 7 THEN 'GOOD'
ELSE 'PERFECT'
END AS RATING
FROM dbo.client
Sure it is possible.
CASE
WHEN CreditRating <= 2 THEN 'NO TRADE'
WHEN CreditRating <= 4 THEN 'POOR'
WHEN CreditRating <= 6 THEN 'AVARAGE'
WHEN CreditRating = 7 THEN 'GOOD'
ELSE 'PERFECT'
END AS RATING
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With