Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Counting in within Data Groups
Message
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00225307
Message ID:
00225426
Views:
11
>>If I reset on AgentID and Customer# then I will only get the number of policies to a each unique AgentID and Customer#. Not the number of unique customers. If I have 1 Agent, 3 Customers, and 10 policies ( a query of 10 records), I want my report to display only 1 line.
>>
>> Agent # of Customer # of Policies
>>Joe Smith 3 10
>>
>>Any help would be appreciated.
>
>If you have the separate report cursor, you may use UDF's called from the report fields to get those numbers. Report field expression for # of Customer"would be:
>
>customers_count(myReportCursor.agentID)
>
> FUNCTION customers_count && say, in you procedure file
>PARAMETER tAgentID
>local lacount[1]
>lacount[1] = 0
>SELECT COUNT(customerID) ;
>FROM myDataTable ;
>WHERE myDataTable.AgentId = tAgentId ;
>INTO ARRAY lacount
>RETURN lacount[1]
>ENDFUNC
>
>
>I often use this trick.

Another way of doing this is to create your report cursor from SQL SELECT with those function calls right in it. In this case the report itself is just a simple one.

***
SELECT agentID, agentName, customers_count(agentID) AS customer_no, ;
policies_count(agentID) AS policies_no ;
FROM myDataTable ;
INTO cursor myReportCursor

Policies_count is the UDF similar to customers_count() function.

Nick
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Reply
Map
View

Click here to load this message in the networking platform