E
E
ebaysher2021-09-01 07:19:25
SQL
ebaysher, 2021-09-01 07:19:25

Can anyone tell me if the sql query is correct?

There are three tables: CUSTOMERS (ID, NAME, MANAGER_ID); MANAGERS (ID, NAME); ORDERS (ID, DATE, AMOUNT, CUSTOMER_ID). Write a query that will display the names of Customers and their SalesManagers who have made purchases totaling more than 10,000 since 01/01/2013.

SELECT customers.name, managers.name
FROM customers JOIN managers JOIN orders
ON (managers.id = orders.customers_id) and (orders.date > 01/01/2013) and (orders.amount > 10000)

Never learned sql , just need to now solve multiple tasks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Akina, 2021-09-01
@ebaysher

The request is syntactically invalid.
1. Each JOIN must have its own ON. It's only MySQL/MariaDB that is loyal to such things.
2. Date literals must be surrounded by quotes - this is at least. And besides, the format of the date literal must clearly correspond to that of the DBMS used - perhaps even a function to convert a string value to a date should be used.
3. Formally - the request must be completed with a semicolon.
The request is logically invalid.
1. There is no connection between the order / manager and the buyer.
2. There is no calculation of the total amount of buyer orders.
3. There is no option when the buyer has a manager in the middle of the period (managers quit, yes ...). However, it is not included in the assignment...
4. The task requires "from 01/01/2013", i.e. inclusive, and strict inequality is used in the selection condition.
Everything else is correct.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question