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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Distinctrow issues - want more detailed output

Status
Not open for further replies.

asrg

Technical User
Jul 11, 2011
9
GB
Hi .. I'm trying to do the following:
I have 2 tables, tblcustomer and tblorders.
I want the output to show the last order (tblorders.orderdate) date of the individual customers
===================================================
Select DistinctRow
tblcustomer.surname
From
tblcustomer Inner Join
tblorders On tblcustomer.CustID = tblorders.CustID
Order By
tblcustomer.surname
==================================================
I get an output thats just a list of customers that have an order, but doesnt show any details, the last order date..

I would like to show the date of the customers last order

Help :)
 
SELECT
tblcustomer.surname
, MAX(tblorders.orderdate) AS LastDate
FROM
tblcustomer LEFT JOIN
tblorders ON tblcustomer.CustID = tblorders.CustID
GROUP BY
tblcustomer.surname
ORDER BY
tblcustomer.surname

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks so much, Im new, so these code snippets help me understand the use in real world.

Great , worked first time :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top