Question from the SQL - Fundamentals test

Write a SQL query to count the number of orders placed by customer 1001.

Expert

Given the following 'orders' table:

| order_id | customer_id | order_date |
|----------|-------------|------------|
| 1        | 1001        | 2022-01-10 |
| 2        | 1002        | 2022-01-11 |
| 3        | 1001        | 2022-01-12 |

Which SQL query/queries count(s) the number of orders placed by customer 1001?

Author: AaronStatus: Published(Update)Question passed 239 times
Edit
0
Community Evaluations
developer avatar
Grégory
11/07/2024
`SELECT COUNT(*) FROM orders WHERE customer_id = 1001;` et `SELECT COUNT(order_id) FROM orders WHERE customer_id = 1001;` sont valides n'est ce pas ? Vu que order_id est PK, cela correspondra Ă©galement au nombre de lignes