If two columns are 1 then make new column

Your query would be:

SELECT PRESENT, WHOLEDAY,
       CASE
           WHEN  (PRESENT = 1 AND WHOLEDAY = 1) THEN 1
           WHEN  (PRESENT = 1 AND WHOLEDAY = 0) THEN 0.5
           ELSE  0
       END as ATTENDANCE 
FROM MY_TABLE

Case Syntax is :

CASE
    WHEN condition_1 THEN commands
    WHEN condition_2 THEN commands
    ...
    ELSE commands
END CASE;

Browse More Popular Posts

Leave a Comment