Created
October 6, 2017 07:36
Star
You must be signed in to star a gist
GROUP BY
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select DISTINCT ON (t.orders) * from (select max(id) id, max(email), max(orders) as orders, campaign_id from coupons group by campaign_id ORDER BY orders DESC) as t ORDER BY t.orders DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment