Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: comparison new and previous purchase price Post Reply Post New Topic
Author Message
p_lsk
Newbie
Newbie


Joined: 13 Apr 2008
Location: Hong Kong
Online Status: Offline
Posts: 3
Quote p_lsk Replybullet Topic: comparison new and previous purchase price
     Posted: 15 Apr 2008 at 7:44am
Hi,
 
I am going to create a report that show today's purchase order details and compare with the previous purchase price.
 
CR Version: 11.5
Purchase record in a table.
 
Record:-
PO no.   Part       Date        unit price        
0403     111        15/4/08       1                    
0402     222        15/4/08       2
0401     111        10/4/08       0.8
 
Report needed:-
Select Date 15/4/08
 
PO no.   Part        unit price       previous unit price
0403     111                1                    0.8
0402     222                2                      -
 
Please advise how to get the "previous unit price".
 
Thanking you in advance.
 
 
 
 
      
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 15 Apr 2008 at 12:37pm
What database are you using?  Do you know how to use SQL?
 
I'm asking because the only way I can think of to get this information is to use a Command.
 
-Dell
IP IP Logged
p_lsk
Newbie
Newbie


Joined: 13 Apr 2008
Location: Hong Kong
Online Status: Offline
Posts: 3
Quote p_lsk Replybullet Posted: 15 Apr 2008 at 8:59pm
The database is PROGRESS and connect via ODBC.
 
I don't know SQL command.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 16 Apr 2008 at 12:26pm
I'm not familiar with PROGRESS.  Do you have a DBA or developer you can talk with about how to write this SQL?
 
As an example, assuming a PO_DETAIL table with the following structure:
 
Cust_Number
PO_Number
Part_Number
PO_Date
Unit_Price
 
The SQL would look something like this (trying to use ANSI Standard SQL - You may have to change it to fit your database):
Select PO_DETAIL.PO_Number, PO_DETAIL.Part_Number,
 PO_DETAIL.PO_Date, PO_DETAIL.Unit_Price,
 PREV_PO_DETAIL.Unit_Price as Prev_Price
from PO_DETAIL
  left outer join PO_DETAIL as PREV_PO_DETAIL on
   PREV_PO_DETAIL.Cust_Number = PO_DETAIL.Cust_Number
   and PREV_PO_DETAIL.Part_Number = PO_DETAIL.Part_Number
   and PREV_PO_DETAIL.PO_Date < PO_DETAIL.PO_Date
where PREV_PO_DETAIL.PO_Date is null
  or PREV_PO_DETAIL.PO_Date =
  (Select Max(CHK_PO_DETAIL.PO_Date)
   from PO_DETAIL as CHK_PO_DETAIL
   where CHK_PO_DETAIL.Cust_Number = PO_DETAIL.Cust_Number 
      and CHK_PO_DETAIL.Part_Number = PO_DETAIL.Part_Number
      and CHK_PO_DETAIL.PO_DATE < PO_DETAIL_DATE)
 
-Dell
 
 
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