Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Selecting only the record with the max date in eac Post Reply Post New Topic
Author Message
Matteo_Luccio
Newbie
Newbie
Avatar

Joined: 30 Jul 2013
Location: United States
Online Status: Offline
Posts: 9
Quote Matteo_Luccio Replybullet 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
IP IP Logged
praveeng
Senior Member
Senior Member
Avatar

Joined: 11 Jul 2011
Online Status: Offline
Posts: 165
Quote praveeng Replybullet Posted: 02 Aug 2013 at 8:25am

Hi Matteo,

Using Group selection formula you can acheive your requirement.
Create a group on Job filed and then in Group selection expert write logic as below,

{Job.Sched_Start} = Maximum ({Job.Job}, {Job.Sched_Start})

HTH

--Praveen G

Praveen Guntuka,
praveen_guntuka@yahoo.com
IP IP Logged
Printable version Printable version

Forum Jump
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