Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Crystal Reports - Distinct field entry (not record) from select

Posted on 2006-10-30
Medium Priority
Last Modified: 2011-08-18
I have a minor problem I would like help with.

I am writing a crystal report that shows how records are moved to a particular area per hour. I am using a table that gives me the record number and the area it is in. The table has an entry added whenever something changes in the record so there will be multiple entries under the same area.

I currently have the report doing a distinct count of the record number in an hourly group, which works fine except that if the record gets updated later on it is getting counted again (in another hour) as the distinct count is only relevant to the hourly group. I want a way to bring in only one (the first ideally) record that shows the area in question per record number.

My select is currently by date range and record area.
Question by:Gryff
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 42

Expert Comment

ID: 17836484
You could probably write your own count formula to only count each record number once.  Something like this:

if {recordNumber} <> Previous({recordNumber}) then

Now you can insert a sum on this formula and that should give you the distinct count.  Your data within the group will need to be sorted by recordnumber for this to work accurately.

LVL 101

Expert Comment

ID: 17837019
The problem as I read it is he has the data grouped by HOUR so that within a group the count is correct but he doesn't want to count a record that is updated at 8AM then again at 10AM twice.

Do you need to show the record each time it is updated or are you simply looking for a count?

If you simply want the count and don't need to see that a record was updated (but not counted) then you could select
based on the date being in range then select only the record with the minimum date in the range.


Author Comment

ID: 17840547
Hey Mlmcc,

You have the problem correctly. I simply want to count how many records are changed to this area.

How do I select the record with the minimum date?
Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

LVL 101

Accepted Solution

mlmcc earned 1000 total points
ID: 17842506
I don't know that you can and still get all of them in the date range?

Can you build a query or stored procedure in the database?


Author Comment

ID: 17843196
I suppose I can write a view, I just prefer to keep things self contained where possible.

Here is what I created in case it comes up for someone else.

create view View_LTX_Area_Arrival
select callaudit_call_num, min(CallAudit_Last_Update) as UpdateTimeDate from sccallaudit
where callaudit_call_area_code = 'LTX'
group by callaudit_call_num

I used crystal to group it by the hour and to pretty it up. I never actually used the call number coming across but I anticipate the manager asking for a similar report with more detail later.

Points to go to Mlmcc as he provided sufficient information to prevent me fruitlessly wasting more time trying to do it in crystal. Thanks guys.
LVL 101

Expert Comment

ID: 17844000
You might try that same SQL as a COMMAND in Crystal.


Author Comment

ID: 17844022
I am using crystal 8.5 (stupid intranet restrictions), and I don't believe that exists in this version. thanks though
LVL 101

Expert Comment

ID: 17844422
YOu are correct, COMMAND was added in CR9


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question