Q:

Need to select most recent record, group by customer and item code

I have a basic order detail table that contains: docDate, customerCode, itemCode, Price, and Quantity. Looked through a number of similar questions, but they didn't seem to take into account everything I need, and I failed to re-purpose the other solutions.
The end goal: Only the most recent record of each individual item ever bought by a customer. (So one record per item)
Prices and quantities change record to record, and I just want the most recent.
This provides me with the most recent entry of each Item (code and date)
SELECT itemCode, MAX(docDate) AS docDate
FROM RDR1 
WHERE customerCode= 'TEST001' 
GROUP BY ItemCode

Now I need to be able to pull the other pieces of information from those most recent rows, like price and quantity.

A:

I think you want to something like this:
   select
    * -- or whatever columns you actually want
    from
    RDR1
    inner join
    (SELECT itemCode, MAX(docDate) AS docDate
    FROM RDR1 
    WHERE customerCode= 'TEST001' 
    GROUP BY ItemCode) MD
    on MD.docDate = RDR1.docDate
and md.ItemCode = RDR1.ItemCode

