19 January 2018

testCheck

My solution:
CREATE PROCEDURE testCheck() 
  SELECT id, 
         IF (given_answer IS NULL, "no answer", CASE 
         WHEN given_answer = correct_answer THEN "correct" 
         ELSE "incorrect" END) AS checks
  FROM   answers 
  ORDER  BY id; 

newsSubscribers

My solution:
CREATE PROCEDURE newsSubscribers() 
  BEGIN 
    SELECT DISTINCT subscriber 
    FROM   full_year 
    WHERE  full_year.newspaper LIKE "%Daily%" 
    UNION 
    SELECT DISTINCT subscriber 
    FROM   half_year 
    WHERE  half_year.newspaper LIKE "%Daily%" 
    ORDER  BY subscriber ASC; 
  END