vendredi 15 juillet 2016

Get last duplicate

My issue is that dupes exist because people make mistakes with our shipping orders and another tracking # is created to fix the order. So I always need to get the last duplicate for an order, so I get the right tracking #.

I have tried this:

SELECT OrderNum, TrackingNumber, CreatedDate, CreatedBy, Carrier
FROM FPDWDB1.Ship.dbo.ShippingLog
GROUP BY OrderNum

I get the following error:

Column 'FPDWDB1.Ship.dbo.ShippingLog.TrackingNumber' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

Aucun commentaire:

Enregistrer un commentaire