I use this query below to get the latest Serial Number that has been added
SELECT
SerialNo,
MAX(AddDate) AS AddDate
FROM
tst_EquipmentItem
WHERE
ControlNo = 'TM-00012'
GROUP BY
SerialNo
ORDER BY
AddDate
OUTPUT:
SerialNo////AddDate
=======================================
TM-00012////2008-08-05 10:25:00.000
Now in the tst_Equipment table there is a ControlNo column. If I include ControlNo to the above statement I get a different output
OUTPUT
SerialNo///ControlNo///AddDate
====================================================
TM-00012///TM-CGI-F-0027///2004-02-09 08:20:00.000
TM-00012///TM-EN-N-0068///2008-08-05 10:25:00.000
How do I include the ControlNo column without having to put it in the GROUP BY Clause so that I can get the latest ControlNo for each SerialNo?
Without knowing your data, I would do: