Question : Record Selection on the Latest Year

Crystal V11.  Trying to select only records for the last year for which there is data in each report group.

Example: Group A may have data for years 2001, 2002, & 2003.  I only want the records from 2003.
Example: Group B may have data for years 2006 & 2007.  I only want the records from 2007.

The year is recorded in a database field as a string with length of 2  ie "07"

Answer : Record Selection on the Latest Year

This is something that would be better handled in your database by a query or SP.

In CR you  could create  a sql query using the Add Command option and base your report on that.

The query would look something like this but you have to use the syntax appropriate to your dbms.

Select * from mytable inner join
(SELECT mytable.groupfield, Max(Year([datefield])) AS mYear
FROM mytable
GROUP BY mytable.groupfield) as q1
On Mytable.Groupfield= q1.groupfield and  year(mytable.datefield) = q1.myear

You have to use your own table and fieldnames of course.
Random Solutions  
 
programming4us programming4us