Click to See Complete Forum and Search --> : Help to return only first row...


SPerkins
November 15th, 2007, 09:25 AM
OK, first off I have only begain to dabble in this side of things, so I am sorry if my descriptions are not concise enough.

I have a very simple query which includes 2 tables, Shipment and Package. The relevent row in Shipment is primary_key, and Package has three which may be relevent, primary_key (unique) foreign_key (refers to shipment.primary_key, there can be many instances) and package_ID (again unique).

I am trying to pull a simple report which shows only the first instance of a match between shipment.primary_key and package.foreign_key.

I have tried all of the joins that I see in the GUI, (equal, left outer, right outer) and these dont seem to work. I have seen articles on max and Nth formulas, but I dont know how I would implement this in crystal.

Thanks in advance for any help I can get.

JaganEllis
November 18th, 2007, 05:32 PM
Inner join on shipment.primary_key and package.foreign_key.
"...which shows only the first instance...". How do you know what this is? Is there something in package that you can sort on?

Group on shipment.primary_key.

There are two main choices for showing only the first record:
1) Sort by package.something. Print in the group header instead, suppress the details.

2) If your package table has a timestamp that you can use as the order then you could use a group selection formula instead to get just the earliest package record per shipment, e.g.
{package.timestamp} = minimum({package.timestamp}, {shipment.primary_key})