Ok, so I'll first admit that I'm not a great SQL writer. I can get by with the basics and am learning more every day.
I haven't had to do this in while.
Here's my current code:
What I need to do is keep my current grouping but instead of max(CEDIVT), I need to take CEDIVT for the most recent date/time of CECRTS.
Any help would be greatly appreciated. I've looked a possible solutions online but the issue is making the data work for my code and I just don't know how to translate it.
Thanks in advance.
I haven't had to do this in while.
Here's my current code:
SQL:
SELECT CHCASN Carton_#, max(CEDIVT) Divert_Location, max(CECRTS) , max(CDTBPU) Units, CDSTYL||CDSSFX||CDCOLR SKU, max(trim(CDAREA)||trim(CDAISL)||trim(CDBAY)||trim(CDLEVL)||trim(CDPOSN)) Pick_Location
FROM ((CHCART00 INNER JOIN CDCART00 ON CHCASN=CDCASN) LEFT OUTER JOIN CECVIF00 ON (CHWHSE=CEWHSE) AND (CHCASN=CECASN)) INNER JOIN WDWAVE00 ON CHPRWV=WDPRWV
WHERE (CHSTAT>'03' AND CHSTAT<'25') AND CHMIS2='' AND CHWHSE='TGL' AND (WDDOWK=1 OR WDDOWK=9)
GROUP BY CHCASN, CDSTYL||CDSSFX||CDCOLR
ORDER BY CHCASN
Any help would be greatly appreciated. I've looked a possible solutions online but the issue is making the data work for my code and I just don't know how to translate it.
Thanks in advance.