Joined: 30 Jul 2013
Location: United States
Online Status: Offline
Posts: 9
Topic: Selecting only the record with the max date in eac Posted: 02 Aug 2013 at 7:47am
I have found many related posts and tried several approaches but none are working and I am still a bit confused, so please be patient with me...
In each group, I need my report to return only the record with the greatest date. My current SQL query is below. As you can see, I am grouping by {Job.Job}; for each job, I want only the record with the maximum date in {Job_Operation.Sched_End}.
I know that there are probably several ways to do this. Please give me the easiest one! Thanks!!
SELECT "Job"."Job", "Job"."Sched_Start", "Job_Operation"."Vendor", "Customer"."Customer", "Job"."Part_Number", "Delivery"."Promised_Date", "Job_Operation"."Status", "Job_Operation"."Sched_End"
FROM ("TECH"."dbo"."Delivery" "Delivery" INNER JOIN ("TECH"."dbo"."Job_Operation" "Job_Operation" INNER JOIN "TECH"."dbo"."Job" "Job" ON "Job_Operation"."Job"="Job"."Job") ON "Delivery"."Job"="Job"."Job") INNER JOIN "TECH"."dbo"."Customer" "Customer" ON "Job"."Customer"="Customer"."Customer"
WHERE ("Job"."Sched_Start">={ts '2013-07-01 00:00:00'} AND "Job"."Sched_Start"<{ts '2013-07-19 00:00:01'}) AND "Job_Operation"."Status"='O'
ORDER BY "Job"."Job"
Matteo
Matteo Luccio, President
Pale Blue Dot, LLC
Writing about geospatial technologies since 2000
www.palebluedotllc.com
541-543-0525
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum