
Originally Posted by
JamesDeckert
What about clicking the totals button then group by ID.
Seems like that would return the top 1 for each ID.
Can you write the sql code please?
Firstly I think directive SELECT TOP xx is performed before GROUP directive, so I still have only 1 record for this query.
Also If I will use aggregate function, I have to use it on all fields. I canīt use GROUP BY only for one field...
I have tried this code and it will give me only one record as a result.
Code:
SELECT TOP 1
tblCustomers.Customer,
tblPMs.EffectiveDate,
tblCustomers.Interval,
tblCustomers.Remarks
FROM
tblCustomers INNER JOIN tblPMs ON tblCustomers.ID = tblPMs.CustomerID
GROUP BY
tblCustomers.Customer,
tblPMs.EffectiveDate,
tblCustomers.Interval,
tblCustomers.Remarks
ORDER BY
tblPMs.EffectiveDate DESC;