I'm trying to create a View in SQL Server equivalent to an Access query that uses 'Last' in 2 columns in order to return only one (the last) of each record. Here is the query that I am trying to convert:
SELECT Max(tblH.HeadID) AS MaxHeadID, tblH.DeliverTo, tblH.Region, tblL.ProdNo, Last(tblH.PODate) AS LastDte, Last(tblL.Qty) AS LastQty
FROM tblH INNER JOIN tblL ON tblH.HeadID = tblL.HeadID
GROUP BY tblH.DeliverTo, tblH.Region, tblL.ProdNo;
I've searched a bunch of SQL Server forums but haven't found any examples that include 2 tables like above. Any help would be greatly appreciated!
Thanks,
Sup
SELECT Max(tblH.HeadID) AS MaxHeadID, tblH.DeliverTo, tblH.Region, tblL.ProdNo, Last(tblH.PODate) AS LastDte, Last(tblL.Qty) AS LastQty
FROM tblH INNER JOIN tblL ON tblH.HeadID = tblL.HeadID
GROUP BY tblH.DeliverTo, tblH.Region, tblL.ProdNo;
I've searched a bunch of SQL Server forums but haven't found any examples that include 2 tables like above. Any help would be greatly appreciated!
Thanks,
Sup