Hi guys!
I'm attempting to write a pretty simple query. Goal is to extract the max ship date associated with a project number, resulting in a single line for each unique project. Unfortunately, the code is returning records for each ship date. Pretty sure there's a missing condition somewhere, but I'm stumped. Any ideas?
Query:
SELECT proj.name "Project Name"
, proj.segment1 "Project Number"
, TRUNC(To_DATE(max(oola.schedule_ship_date), 'DD-MON-YY')) "Oracle Ship Date"
FROM oe_order_lines_all oola
, pa_projects_all proj
WHERE proj.project_id = oola.project_id
AND oola.flow_status_code IN ('AWAITING_SHIPPING','BOOKED', 'ENTERED', 'AWAITING_FULFILLMENT', 'AWAITING_RETURN', 'CLOSED')
AND proj.project_status_code not like 'CLOSED'
AND proj.segment1 like '650%'
GROUP BY proj.name, proj.segment1, oola.schedule_ship_date
ORDER BY proj.segment1
Output:
| Project Name | Project Number
| Oracle Ship Date |
|---|
| Horse | 123 | 1/1/2018 |
| Horse | 123 | 4/2/2018 |
| Horse | 123 | 6/3/2018 |
| Pig | 234 | 2/5/2018 |
| Pig | 234 | 12/10/2018 |
| Monkey | 345 | 5/25/2018 |
| Monkey | 345 | 6/19/2018 |
| Monkey | 345 | 6/28/2018 |
Desired Output:
| Project Name | Project Number | Oracle Ship Date
|
|---|
| Horse | 123 | 6/3/2018 |
| Pig | 234 | 12/10/2018 |
| Monkey | 345 | 6/28/2018 |