Skip to content

Instantly share code, notes, and snippets.

@remilapeyre
Last active July 29, 2024 12:13
Show Gist options
  • Save remilapeyre/7bfd0eaf9fe67b420bc4995c38325c86 to your computer and use it in GitHub Desktop.
Save remilapeyre/7bfd0eaf9fe67b420bc4995c38325c86 to your computer and use it in GitHub Desktop.
Tables:
- User (user_id varchar, user_name varchar, user_email varchar)
- Order (order_id varchar, user_id varchar, date timestamp)
- Product (product_id varchar, product_name varchar, price integer)
- ProductOrder (order_id varchar, product_id varchar, quantity integer)
Write the SQL query to get for each user the 5 products they ordered the most over the last 7 days.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment