Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Latest recorded Date info ONLY Post Reply Post New Topic
Author Message
FanieF
Newbie
Newbie
Avatar

Joined: 12 Aug 2008
Location: South Africa
Online Status: Offline
Posts: 2
Quote FanieF Replybullet Topic: Latest recorded Date info ONLY
    Posted: 12 Aug 2008 at 7:58am

Select Last date updated only - I have numerous codes, each with a cost and sell price linked to it, but whenever a price is updated, the previous 'old' price is remembered. The unique selection is the date updated.

If I extract the sell prices, updated in, say 2008, I get all the old prices, as well as the latest price, if they were changed in 2008. The Update-dates are not always on the same day, so I cannot use a selection by date only.
 
How do I get Crystal to display ONLY the last updated price, and not all the updated prices for each stock code, for all the codes in one report?
 
I can do it in Excel, but it is a schlep to do this every time I need to check the sell or Cost prices for all the items.
 
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 12 Aug 2008 at 12:19pm

You'll have to use a command in order to get this information.  You don't mention what type of DB you're connecting to, but commands are available for most client/server databases like MS SQL Server or Oracle.  A command is a SQL "Select" statement that you enter in Crystal.

You can approach this two different ways:
 
1.  Write a SQL statement that will give you all of the data you need for your report.  It will look something like this:
Select ct.Code_Field, ct.Cost, ct.Sell_Price
From Code_Table as ct
where ct.Date_Updated =
  (Select max(ct1.Date_Updated)
   from Code_Table as ct1
   where ct1.Code_Field = ct.Code_Field)
 
If you have multiple tables in your report, this can get complicated and you need to know SQL well enough to write a good query.
 
2. Write a query that just gives you the code field and the max of the update date, something like this:
 
Select Code_Field, max(Date_Updated)
From Code_Table
Group By Code_Field
Order By Code_Field
 
Link from the code and date updated fields in Code table you already have in the report to the code and date updated fields in the command.  This will guarantee that the records that are on your report are only the most recent ones.
 
-Dell
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.