How to pull first line of data from multiple rows
Printed From: Crystal Reports Book — Forum Name: Technical Questions
Posted By: SNelson — 24 Oct 2017 at 8:39am
I need to select the first record for each 'customer' in my database. There is a field that has the row/record number for each customer but this number doesn't always start with '1'. Is there a way to select the record based on the minimum value of this field? Or another way?
In the select expert the only options are less than, greater than, equal to, etc. This doesn't work b/c the minimum value isn't the same for each customer.
Thanks for any help!
Posted By: kevlray — 24 Oct 2017 at 11:23am
Sort of. You can group by 'customer' and display the information in the group header (suppress the detail). Not sure what will determine the first row though for each customer.
Posted By: SNelson — 25 Oct 2017 at 9:58am
I've also created a running total, which does let me number by customer beginning from 1, but I can't use that in the select expert.
I wondered if an SQL query would work instead. I've seen something similar using this idea:
( select
min(case...)
)
|