Skip to content

Instantly share code, notes, and snippets.

@mattm
Created November 12, 2018 17:22
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 mattm/e4dd42da1182fee020f7eb966e19a7dd to your computer and use it in GitHub Desktop.
Save mattm/e4dd42da1182fee020f7eb966e19a7dd to your computer and use it in GitHub Desktop.
Grouping Styles
# Good: Grouping by column number
...
select
email,
min(expressed_interest_at) as expressed_interest_at
from unioned
group by 1
order by 2
...
# Good: Grouping by column name
...
SELECT a.email, min(b.created_at) AS expressed_interest_at
FROM hubspot.contact AS a
JOIN helpscout.conversation AS b ON a.email = b.email
GROUP BY a.email
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment