Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WITH
- e AS (SELECT COUNT(DISTINCT(instituition)) AS No_of_instituitions,
- person_id
- FROM education
- GROUP BY person_id),
- c AS (SELECT name,
- id
- FROM company)
- SELECT c.name,
- e.No_of_instituitions
- FROM people AS p
- INNER JOIN e ON e.person_id = p.id
- INNER JOIN c ON c.id = p.company_id
- ORDER BY e.No_of_instituitions DESC
- LIMIT 5;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement