SHARE
TWEET

Untitled

a guest Feb 17th, 2017 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT forename , COUNT(forename) AS popularity
  2. FROM                    (
  3.                             SELECT SUBSTRING(name FROM 1 FOR POSITION(' ' IN name) - 1) AS forename
  4.                             FROM person
  5.                             WHERE name LIKE '% %'
  6.                             UNION ALL
  7.                             SELECT name AS forename
  8.                             FROM person
  9.                             WHERE name NOT LIKE '% %'
  10.                   ) AS list_of_forenames
  11. GROUP BY forename
  12. HAVING COUNT(forename) > 1
  13. ORDER BY popularity DESC, forename ASC
RAW Paste Data
Top