Skip to content

Instantly share code, notes, and snippets.

@championswimmer
Created June 8, 2018 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save championswimmer/2ceb824172fba7807c84ccf1dcc8bce0 to your computer and use it in GitHub Desktop.
Save championswimmer/2ceb824172fba7807c84ccf1dcc8bce0 to your computer and use it in GitHub Desktop.
all users with one verified and multiple unverified accounts
SELECT
count("email") AS "count",
count("verifiedemail") as "Verified",
max("createdAt") as "Last Attempt",
min("createdAt") as "First Attempt",
"public"."users"."email" AS "email"
FROM "public"."users"
GROUP BY "public"."users"."email"
HAVING
count("email") > 1 AND
count("verifiedemail") = 1
ORDER BY "count" DESC, "public"."users"."email" ASC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment