Answer the question
In order to leave comments, you need to log in
Help with basic SQL queries?
There are three tables - traffic, managers, clients.
Cargo table: record number (id), container (container), link to the client (id_client), link to the manager (id_manager), date of actual arrival of the cargo (arriving_date).
Table of managers: record number (id), last name (surname), first name (name), mail (mail), phone (phone).
Customer table: record number (id), company name (name), TIN (INN), address (address), mail (mail), telephone (phone).
Please help me with these questions, 4 seems wrong to me, and 5 and 7 I can't think
of 4. Select clients who have cargo on the way
SELECT clients.id FROM traffic INNER JOIN ON traffic.id_client=clients.id WHERE arriving_date IS NOT null or arriving_date != ' '
5. Select clients whose cargoes are handled by the manager Natalia
7. Number of cargoes for each client.
Answer the question
In order to leave comments, you need to log in
In order
SELECT c.*
FROM clients c
LEFT JOIN traffic t ON t.client_id = c.id
WHERE t.arriving_date ISNULL
SELECT c.*
FROM clients c
LEFT JOIN traffic t ON t.id_client = c.id
LEFT JOIN managers m ON t.id_manager = m.id
WHERE m.name = 'Наталья'
SELECT t.id_client,
count(*)
FROM traffic t
GROUP BY id_client
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question