Created
October 6, 2022 03:38
-
-
Save rosousa/7f46bc99f584293aae6f11d16adeedd7 to your computer and use it in GitHub Desktop.
Prática - Exercícios Group By
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
--Q1: | |
SELECT COUNT("endDate") "currentExperience" FROM experiences; | |
--Q2: | |
SELECT "userId" id, COUNT(*) "educations" FROM educations GROUP BY "userId"; | |
--Q3: | |
SELECT users.id, users.name writer, COUNT(*) "testimonialCount" FROM testimonials JOIN users ON testimonials."writerId" = users.id WHERE users.id = 435 GROUP BY users.id; | |
--Q4: | |
SELECT MAX(jobs.salary) "maximumSalary", roles.name role FROM jobs JOIN roles ON jobs."roleId" = roles.id WHERE jobs.active = true GROUP BY roles.name ORDER BY "maximumSalary"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment