?
Solved

Count subtotal bands in a VFP 9 report

Posted on 2011-09-26
4
Medium Priority
?
774 Views
Last Modified: 2012-05-12
Is there a way to get the number of subtotal bands in a Foxpro report?

In my specific instance, I need to find out how many distinct families a teacher as well as how many children she has, where there may be more than one child from each family being served by the same teacher...

For example:

Teacher A

Joe Smith
John Doe
Jill Doe

3 students
2 families


I'm trying to get my data prepared as follows; the question is - how can I get a count of the number of families served by the teacher.

CLOSE TABLES all
SET SAFETY OFF

SELECT * FROM cases,teacher WHERE cases.cidinte = teacher.cidinte AND status = "A" ORDER BY fullname INTO table SYS(2023)+"\inter_case"

SELECT 0
USE children ORDER cidchil
SELECT 0
USE family ORDER cidfami

SELECT inter_case

SET RELATION TO cidchil INTO children
SELECT children
SET RELATION TO cidfami INTO family

SELECT inter_case
INDEX on fullname + family.familyname + children.fname TO SYS(2023)+"\inter_case"
GO TOP
BROWSE FIELDS inter_case.fullname,family.familyname,children.fname,children.lname,inter_case.date_assig

0
Comment
Question by:AndrewJen
  • 3
4 Comments
 
LVL 43

Expert Comment

by:pcelba
ID: 36598883
You are not disclosing your data model, so the solution is just a brief estimation:

SELECT Teacher, COUNT(DISTINCT Family) AS Families, COUNT(*) AS Childrens
  FROM YourTable
  GROUP BY 1
  INTO CURSOR cResult

Now you may index the result on Teacher and use it in the report.
0
 
LVL 43

Expert Comment

by:pcelba
ID: 36598889
The above "YourTable" must contain all childrens and their appropriate teachers.
0
 
LVL 3

Author Comment

by:AndrewJen
ID: 36598947
Thanks for the tip, I'm trying the following and getting an error "Group by Clause is missing or invalid"


SELECT fullname,COUNT(distinct(familyname)),children.fname,children.lname,cases.status FROM intervent,family,children,cases WHERE intervent.cidinte = cases.cidinte ;
AND children.cidchil = cases.cidchil .and. family.cidfami = children.cidfami GROUP BY 1

0
 
LVL 43

Accepted Solution

by:
pcelba earned 2000 total points
ID: 36599011
GROUP BY must be defined for all non-aggregated columns, so:

SELECT fullname, COUNT(distinct(familyname)), ;
       children.fname, children.lname, cases.status ;
  FROM intervent, family, children, cases ;
 WHERE intervent.cidinte = cases.cidinte ;
   AND children.cidchil = cases.cidchil ;
   AND family.cidfami = children.cidfami ;
 GROUP BY 1, 3, 4, 5

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
I came across an unsolved Outlook issue and here is my solution.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

809 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