Skip to content

Instantly share code, notes, and snippets.

@cfigueiroa
Last active February 15, 2023 22:55
Show Gist options
  • Save cfigueiroa/24e643f448a1142b30f3df528da3ba1e to your computer and use it in GitHub Desktop.
Save cfigueiroa/24e643f448a1142b30f3df528da3ba1e to your computer and use it in GitHub Desktop.
-- 1
SELECT COUNT("endDate") AS "currentExperiences" FROM experiences;
-- SELECT COUNT(*) AS "currentExperiences" FROM experiences WHERE "endDate" IS NOT NULL;
-- 2
SELECT "userId" AS id, COUNT(*) AS educations FROM educations GROUP BY "userId" ORDER BY id ASC;
-- 3
SELECT users.name as writer, COUNT(*) as "testimonialCount" from testimonials JOIN users ON users.id = testimonials."writerId" GROUP BY users.name ORDER BY users.name ASC;
-- 4
SELECT MIN(jobs.salary) AS "maximumSalary", roles.name AS "role" FROM roles JOIN jobs ON roles.id = jobs."roleId" 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