Answers for "case set SQL"

SQL
2

sql case

Change query output depending on conditions.
Example: Returns users and their subscriptions, along with a new column
called activity_levels that makes a judgement based on the number of
subscriptions.
SELECT first_name, surname, subscriptions
CASE WHEN subscriptions > 10 THEN 'Very active'
WHEN Quantity BETWEEN 3 AND 10 THEN 'Active'
ELSE 'Inactive'
END AS activity_levels
FROM users;
Posted by: Guest on January-07-2021
1

Case in sql

SELECT OrderID, Quantity,
CASE
    WHEN Quantity > 30 
  THEN 'The quantity is greater than 30'
    WHEN Quantity = 30 THEN 'The 
  quantity is 30'
    ELSE 'The quantity is under 30'
END AS QuantityText
FROM OrderDetails;
Posted by: Guest on August-12-2021
0

sql case sttement with set

UPDATE dbo.TestStudents  
SET     LASTNAME =  CASE  
                        WHEN LASTNAME = 'AAA' THEN 'BBB' 
                        WHEN LASTNAME = 'CCC' THEN 'DDD' 
                        WHEN LASTNAME = 'EEE' THEN 'FFF' 
                        ELSE LASTNAME
                    END 
WHERE   LASTNAME IN ('AAA', 'CCC', 'EEE')
Posted by: Guest on August-25-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language