Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Querying Issue. Post Reply Post New Topic
Author Message
steve_r18
Newbie
Newbie


Joined: 30 Sep 2011
Location: Canada
Online Status: Offline
Posts: 10
Quote steve_r18 Replybullet Topic: Querying Issue.
     Posted: 22 Nov 2011 at 6:25am
Hey everyone,

I'm looking for some help trying to isolate some records in a report I'm making.

Issue: example

Many customers (cust_ID) have multiple types of accounts (chequing and savings) but I need to narrow down those customers who only have savings accounts.

So far my query contains a list of customer_ID's and grouped by customer_ID, but they have multiple accounts under each customer_ID. I need those which customer ID's only have savings account. If I filter by savings only, it's possibly they have chequing aswell. I thought it would be fairly straight forward, I can't seem to think right now.

Help please??

Thanks.

Steve
IP IP Logged
steve_r18
Newbie
Newbie


Joined: 30 Sep 2011
Location: Canada
Online Status: Offline
Posts: 10
Quote steve_r18 Replybullet Posted: 23 Nov 2011 at 1:51am
So while everyone was so quick to respond, I was able to identify account that have a savings only using only 1 unique identifier for each account. The only issue now is that it won't let me filter using the custom function I created. Any idea why I can't use the custom function, or how I could make this work?

I basically assigned values to account type (e.g, savings = 1, chequing = 99. If the total value for the account was more than 1 , give me a yay or nay....

....any ideas anyone?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 23 Nov 2011 at 4:52am
well, looking at the time stamps, I think that most of us log on early in the day, and then we have to work, so...
 
It doesn't work because CR doesn't 'know' the total at the time that is it reading/filtering the data.
 
So how can we get around this? There is my easy answer, use a stored procedure to select your data, as you can filter easily in the stored proc.  Due to causality, I can't think of a way to filter the data by joining straight to the tables....well how about this, I can't guarantee that it will work, but it should come close.
 
Using the command object, write a query that sums the values (like in your custom function) tied to the customer id, something like:
select customerid, ck = sum(case when account type = check then 99 else 1 end) from account table group by customerid.
 
now you can link your physical tables to the command object and filter all command object records to where the ck < 99 in the record selection formulas (i am assuming that if they have 3 saving accounts you would still want to see them...)
 
if nothing else, it might be a path to the final solution.
 
HTH
 
 
IP IP Logged
steve_r18
Newbie
Newbie


Joined: 30 Sep 2011
Location: Canada
Online Status: Offline
Posts: 10
Quote steve_r18 Replybullet Posted: 23 Nov 2011 at 7:05am
Thanks lockwelle,

I was able to sum the existing value and have the value placed in each header, allowing the filtering based on values to work.
IP IP Logged
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