Informatics Practices
Below are the customer and order tables :
Customers
| customer id (PK) |
|---|
| first_name |
| last_name |
| address |
| city |
| state |
| zip |
Orders
| order id (PK) |
|---|
| order_date |
| amount |
| customer_id (FK) |
List all customers (name) who have orders (use EXISTS).
SQL Queries
3 Likes
Answer
SELECT first_name, last_name
FROM Customers c
WHERE EXISTS (
SELECT first_name, last_name
FROM Orders o
WHERE o.customer_id = c.customer_id
);
Answered By
2 Likes
Related Questions
List the maximum salary of employee grouped by their department number.
Below are the customer and order tables :
Customers
customer id (PK) first_name last_name email address city state zip Orders
order id (PK) order_date amount customer_id (FK) List the total of customers' orders grouped by customer (id).
Below are the customer and order tables :
Customers
customer id (PK) first_name last_name email address city state zip Orders
order id (PK) order_date amount customer_id (FK) List the sum of the totals of orders grouped by customer and state.
Below are the customer and order tables :
Customers
customer id (PK) first_name last_name email address city state zip Orders
order id (PK) order_date amount customer_id (FK) List the sum of the totals of orders where this sum is greater than $1000 grouped by customer (id) and state and ordered by state.