Last active
January 30, 2018 12:01
-
-
Save HubertArciszewski95/70184c36889157c036c17a5ee40b3689 to your computer and use it in GitHub Desktop.
Syntax form test in MySQL course
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
first_name, | |
last_name, | |
COUNT(rating) AS count, | |
IFNULL(MIN(rating),0) AS min, | |
IFNULL(MAX(rating), 0) AS max, | |
ROUND(IFNULL(AVG(rating), 0), 2) AS avg, | |
CASE | |
WHEN COUNT(rating) > 0 THEN 'ACTIVE' | |
ELSE 'INACTIVE' | |
END AS 'STATUS' | |
FROM reviewers | |
LEFT JOIN reviews | |
ON reviewers.id = reviews.reviewer_id | |
GROUP BY reviewers.id | |
ORDER BY rating DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment