Hello all,
I have a table showing the OrderHistory for Purchase Orders. Sample attached.
I would like to pull out the DateAuthorised for the latest Version for each OrderGUID, i.e. the yellow highlighted dates. How can I do this in PQ?
I then merge with another table against OrderGUID.
Thanks
Rich
As per the below SQL (I'm still learning SQL so may be a bit rough around the egdes):
SELECT OH1.OrderGUID, OH1.Version, OH1.DateAuthorised
FROM db
rderHistory AS OH1
WHERE OH1.Version =
(SELECT MAX(OH2.Version) as MaxVersion
FROM db
rderHistory AS OH2
WHERE OH2.OrderGUID = OH1.OrderGUID AND OH2.DateAuthorised IS NOT NULL)
I have a table showing the OrderHistory for Purchase Orders. Sample attached.
I would like to pull out the DateAuthorised for the latest Version for each OrderGUID, i.e. the yellow highlighted dates. How can I do this in PQ?
I then merge with another table against OrderGUID.
Thanks
Rich
As per the below SQL (I'm still learning SQL so may be a bit rough around the egdes):
SELECT OH1.OrderGUID, OH1.Version, OH1.DateAuthorised
FROM db
WHERE OH1.Version =
(SELECT MAX(OH2.Version) as MaxVersion
FROM db
WHERE OH2.OrderGUID = OH1.OrderGUID AND OH2.DateAuthorised IS NOT NULL)