Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Record Selection Post Reply Post New Topic
Author Message
iceuser1
Newbie
Newbie
Avatar

Joined: 03 Oct 2007
Location: United States
Online Status: Offline
Posts: 2
Quote iceuser1 Replybullet Topic: Record Selection
    Posted: 03 Oct 2007 at 11:34am
I need to felect records from a group,  Case example;
A Many to many relationship exists, multiple Parts (text string) with multiple Purchase orders (text string), I want to Append to the Part record  the latest (by date) PO record for each part The result would be a single record for each part in the set.  with the patest PO (if any). If there is no PO for the Part I wish to keep the Part record with a null in the PO field>
 
Thanks in advance for any help, I am in the learn as you go phase here Angry
js
IP IP Logged
jkwrpc
Senior Member
Senior Member


Joined: 19 Jun 2007
Location: United States
Online Status: Offline
Posts: 432
Quote jkwrpc Replybullet Posted: 04 Oct 2007 at 7:14am

Is it possible to link this information through another table in your database that would help identify which PO goes with which Part? Is there some form of a Primary Key - Foriegn Key relationship?

It would also help to have a better desciption of the data. At least it would help me. If you could show us a sample from the data fields in their raw form and the desired results you are looking for.
 
Regards,
 
John W.
IP IP Logged
iceuser1
Newbie
Newbie
Avatar

Joined: 03 Oct 2007
Location: United States
Online Status: Offline
Posts: 2
Quote iceuser1 Replybullet Posted: 04 Oct 2007 at 10:14am
Thanks for your reply, here is how the data is stored:
 
Table 1
 
Part number   |   Requisition Number    |    Order Qty   |    Place Date
12345                 10000                              10                    10/5/2007
12345                 10001                              15                    11/30/2007
67891                 10002                              100                  10/5/2007
67891                 10003                              150                  12/10/2007
 
Table 2
 
Part number   |   PO # and Line #         |   Vendor #  |  Unit Cost |    | Date
12345                 900               Ln # 1                 01           $ 1.00       8/1/07
12345                 900               Ln # 2                 01           $ 1.00       7/1/07
12345                 875               Ln # 2                 01           $ 1.00       5/5/07
12345                 750               Ln # 1                 02           $ 1.17     12/5/06
 
67891                 920                                      03            $ 2.00      8/10/07
67891                 850                                      03            $ 2.00      4/9/07
67891                 725                                      04            $ 2.75      1/10/07
 
Table 3
 
Vendor Number    |    Vendor Name
01                              ACME Supply
02                              Electronic Dist.
03                              Aero Machine
04                             #1 Machine
 
I want to associate the latest data from Table 2 (Last PO for That Part # and last paid price) along with Vendor Name from Table 3 to each record in table 1. 
 
Currently My report will output each record in table 1 duplicated for every record in table 2 joining on the Primary key:  (Part number) an example of the outpt is:
 
12345    10000             10        10/5/2007      ACME Supply   $ 1.00
12345    10001             15        11/30/2007    ACME Supply   $ 1.00
12345    10000             10        10/5/2007      ACME Supply   $ 1.00
12345    10001             15        11/30/2007    ACME Supply   $ 1.00
12345    10000             10        10/5/2007      ACME Supply   $ 1.00
12345    10001             15        11/30/2007    ACME Supply   $ 1.00
12345    10000             10        10/5/2007      Electronic Dist. $ 1.17
12345    10001             15        11/30/2007    Electronic Dist. $ 1.17
 
I understand how I get these results (Primary Key = Part Number) what I can't figure out is how to select only the latest record for each part,
 
I have tried Maximum formulas  for group selection in a Stand alone report against Table 2 only:
 
{poa.poa_stsdte}= Maximum ({poa.poa_stsdte},{pos.pos_itemno} ) and
{pos.pos_orderno}=Maximum ({pos.pos_orderno},{pos.pos_itemno} )and
{pos.pos_lnno}=Maximum ({pos.pos_lnno},{pos.pos_itemno} )
 
that works I get one record for each Part,  I dont Know how to Tie this logic into the Associative report with  Purchase reqs. this is the result I need:
 
 
P/N       |   Req #    |    Order Qty   |    Place Date    |  Vendor   |  Price
12345      10000               10              10/5/2007      ACME          $1.00
12345      10001               15              11/30/2007    ACME          $1.00
67891      10002               100            10/5/2007      Aero Mach  $ 2.00
67891      10003               150            12/10/2007    Aero Mach  $ 2.00
js
IP IP Logged
jkwrpc
Senior Member
Senior Member


Joined: 19 Jun 2007
Location: United States
Online Status: Offline
Posts: 432
Quote jkwrpc Replybullet Posted: 06 Oct 2007 at 7:49am
Sorry for being so slow in getting back to you. My agency suffered an major office flood and I have been consumed relocating and restoring the staff to operations for the past 3 weeks.
 
I have looked through the data. It does seem that the the requisition number changes for each order, even though its the same PO and regardless of date. If that is correct ( I could certainly be wrong) then it seems to me it may a better tool than the date.
 
You could create a SQL something like this, I will just write out my logic you will have to fill in the data fields.
 
SELECT records FROM table 2 LEFT OUTER JOIN table 1 ON partnumber = partnumber GROUP BY partnumber requistion number HAVING max(requisition number)
 
The HAVING statement should limit the records to those with the largest (i.e most recent) requisition number. You could do the same with the dates, but dates can be quirky to deal with.
 
That would go in one command object (Records)  then I would add a second command object (VendorInfo) and SELECT the records FROM table 3.
 
Then in database expert I would link Table 3 (Vendors Info) to the other command object (Records) on the Vendor ID fields.
 
You may have to tweak the logic but it should get you close.
 
Hope this helps.
 
Regards,
 
John W.
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.016 seconds.