P
P
Pasha2017-02-05 14:12:32
SQL
Pasha, 2017-02-05 14:12:32

How to display the names of buyers whose order was shipped after the required date?

Hello!
I have 2 tables - Orders , Customers
in Orders there are columns RequiredDate, ShippedDate
in Customers column ContactName
I need to find out the names of those whose orders were shipped after RequiredDate, during 1997
What I did: Select distinct contactname,orderdate from customers left join orders on year(orderdate) = 1997
how to find out which orders were sent after RequiredDate?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2017-02-05
@DoneBass

orders on
->WHERE
SELECT Customers.ContactName, COUNT(Orders.ID) AS [Число просроченных]
  FROM Customers INNER JOIN Orders ON Customers.ID = Orders.Customer
  WHERE (Orders.RequiredDate < Orders.ShippedDate)
  GROUP BY Customers.ContactName
  HAVING (COUNT(Orders.ID) > 0)
  ORDER BY Customers.ContactName

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question