Skip to content

Instantly share code, notes, and snippets.

@mattm
Created November 12, 2018 17:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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