Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DISTINCT QUERY QUESTION 2

Status
Not open for further replies.

ietprofessional

Programmer
Apr 1, 2004
267
US
Table Data
-----------
CompanyName1 - DateEntered

John's Furniture - 02/05/05
John's Furniture - 02/02/05
Jack's Furniture - 01/09/05
John's Furniture - 01/03/05
Jack's Furniture - 11/09/04

From this data how could I pull just this
Jack's Furniture - 01/09/05
John's Furniture - 02/05/05

Notice that it is the latest date entered for both companies. Keep in mind in the real table there will be dozens of companies.

How can I only pull each company once and also the one with the latest date?

THANKS!




 
Select CompanyName1, Max(DateEntered)
From Table
Group By CompanyName1
 
Code:
SELECT companyname1, MAX(dateentered)
FROM t
GROUP BY companyname1

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top