Most recent order date for all employees

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a school assignment where I'm supposed to pull the above info using
SQL statements. I looked thru old postings & tried this:

SELECT EmployeeID, OrderDate
FROM Orders
WHERE OrderDate =
(SELECT Max(OrderDate) FROM Orders);

It gave me the below & didn't include the other employees whose most recent
order was earlier than this date:

EmployeeID OrderDate
1 05-Jun-96
4 05-Jun-96
7 05-Jun-96
8 05-Jun-96
 
Tina said:
I have a school assignment where I'm supposed to pull the above info using
SQL statements. I looked thru old postings & tried this:

SELECT EmployeeID, OrderDate
FROM Orders
WHERE OrderDate =
(SELECT Max(OrderDate) FROM Orders);

It gave me the below & didn't include the other employees whose most recent
order was earlier than this date:

EmployeeID OrderDate
1 05-Jun-96
4 05-Jun-96
7 05-Jun-96
8 05-Jun-96

To paraphrase your assignment: "Most recent order date *by employee*"
suggests you need a GROUP BY clause somewhere?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top