1596. The Most Frequently Ordered Products for Each Customer
https://leetcode.com/problems/the-most-frequently-ordered-products-for-each-customer
Description
Table: Customers
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| customer\_id | int |
| name | varchar |
+---------------+---------+
customer\_id is the primary key for this table.
This table contains information about the customers.Table: Orders
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| order\_id | int |
| order\_date | date |
| customer\_id | int |
| product\_id | int |
+---------------+---------+
order\_id is the primary key for this table.
This table contains information about the orders made by customer\_id.
No customer will order the same product **more than once** in a single day.Table: Products
Write an SQL query to find the most frequently ordered product(s) for each customer.
The result table should have the product_id and product_name for each customer_id who ordered at least one order. Return the result table in any order.
The query result format is in the following example:
ac
Previous1595. Minimum Cost to Connect Two Groups of PointsNext1597. Build Binary Expression Tree From Infix Expression
Last updated
Was this helpful?