Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Most recent record, only select fields Post Reply Post New Topic
Author Message
Ditdah
Newbie
Newbie


Joined: 27 Jun 2011
Location: United States
Online Status: Offline
Posts: 2
Quote Ditdah Replybullet Topic: Most recent record, only select fields
     Posted: 27 Jun 2011 at 7:11am
Hi there,
 
I'm struggling with a report I'm building for a pharmacy. What we need is a report of all prescriptions that haven't been picked up (or, at least, according to the computer.)
 
Each prescription has a "ticket" associated with it, and all actions on that prescription add another ticket status. The status is designated as a 2-digit code. So, for prescription A1234, it gets entered (NW status, for new), filled (FL), checked (CK), and picked up (PU.) Each of these statuses has sequential number assigned, as follows:
 
 
RX Status Tix Seq
A1234 PU 1105491
A1234 CK 1105452
A1234 FL 1104414
A1234 NW 1104411
A1235 CK 1105492
A1235 FL 1105453
A1235 NW 1105418
 
If I group them by RX and then by Ticket sequence, and use the following group selection formula
 
{TICKET.TICKETSEQ} = maximum ({TICKET.TICKETSEQ}, {TICKET.RX})
 
Then I get the following report, pulling only the most recent transaction for each prescription:
 
RX Status Tix Seq
A1234 PU 1105491
A1235 CK 1105492
 
My question is, however, how do I get the report to only pull the records where the most recent status is not PU? In the example report, I would like to see only A1235, since it hasn't been picked up, but I would not like to see A124.
 
I'm sure this is easier than I'm making it, but I can't figure out how to make it happen.
 
Can anyone offer some suggestions? And please let me know what other information I should provide...
Thanks so much!
 


Edited by Ditdah - 27 Jun 2011 at 7:14am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 Jun 2011 at 7:15am

can you use a stored proc or view or do you have to do this all in crystal?

IP IP Logged
Ditdah
Newbie
Newbie


Joined: 27 Jun 2011
Location: United States
Online Status: Offline
Posts: 2
Quote Ditdah Replybullet Posted: 27 Jun 2011 at 7:55am
It would be best if it could all be in Crystal, as the person who is going to be running it goes into Crystal each day and just refreshes all of her reports and prints them. My first response was to tell her to export it into Excel for sorting and deleting anything with the PU status, but that caused confusion...
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 Jun 2011 at 8:12am
you can use a crystal command to get the data as your source
 
 
SELECT     TICKET.TICKETSEQ, TICKET.RX, TICKET.STATUS
FROM         TICKET INNER JOIN
                          (SELECT     RX, MAX(TICKETSEQ) AS Max_Seq
                            FROM          TICKET AS TICKET_1
                            GROUP BY RX) AS V ON TICKET.RX = V.RX AND TICKET.RX= V.Max_Seq
WHERE     (TICKET.STATUS <> 'PU')
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