This file contains 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 salary * months AS earnings, COUNT(*) FROM Employee | |
GROUP BY earnings ORDER BY earnings DESC LIMIT 1; |
This file contains 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 CEIL(AVG(Salary) - AVG(REPLACE(Salary, 0, ""))) FROM EMPLOYEES; |
This file contains 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 MAX(POPULATION) - MIN(POPULATION) FROM CITY; |
This file contains 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 SUM(POPULATION) FROM CITY WHERE COUNTRYCODE = "JPN"; |
This file contains 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 FLOOR(AVG(POPULATION)) FROM CITY; |
This file contains 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 AVG(POPULATION) FROM CITY WHERE DISTRICT = "California"; |
This file contains 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 SUM(POPULATION) FROM CITY WHERE DISTRICT = "California"; |
This file contains 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 COUNT(*) FROM CITY WHERE POPULATION > 100000; |
This file contains 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
SET @r1=0, @r2=0, @r3=0, @r4=0; | |
SELECT MIN(Doctor), MIN(Professor), MIN(Singer), MIN(Actor) | |
FROM( | |
SELECT | |
CASE | |
WHEN Occupation="Doctor" THEN (@r1:=@r1+1) | |
WHEN Occupation="Professor" THEN (@r2:=@r2+1) | |
WHEN Occupation="Singer" THEN (@r3:=@r3+1) | |
WHEN Occupation="Actor" THEN (@r4:=@r4+1) | |
END AS RowNumber, |
This file contains 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 CONCAT(NAME, "(", LEFT(OCCUPATION, 1), ")") FROM OCCUPATIONS ORDER BY NAME; | |
SELECT CONCAT("There are a total of ", COUNT(OCCUPATION), " ", LOWER(OCCUPATION), "s.") | |
FROM OCCUPATIONS GROUP BY OCCUPATION ORDER BY COUNT(OCCUPATION), OCCUPATION; |