Skip to content

Instantly share code, notes, and snippets.

@gmyrianthous
Created September 4, 2022 14:04
Show Gist options
  • Save gmyrianthous/292c3a69a938f8e76d9158422349ed4b to your computer and use it in GitHub Desktop.
Save gmyrianthous/292c3a69a938f8e76d9158422349ed4b to your computer and use it in GitHub Desktop.
SELECT DISTINCT ON (customer_id) customer_id, store_id
FROM rental_example
ORDER BY customer_id, amount;
/*
|customer_id|store_id|
|-----------|--------|
| 58 | 2 |
| 100 | 6 |
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment