Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Unique counts - subtotals
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00455221
Message ID:
00456349
Views:
20
I think I got what you are looking for. This requires your table to have a unique record id [PK]. This is represented by KEYID in my SQL. I have also used CUSTID instead of ID in my SQL.
select custid, keyid from patients where between(age, 0, 18) group by custid into cursor crsUniqueChildren
select custid, keyid from patients where age > 18 group by custid into cursor crsUniqueAdults

select insurance, count(*) kount from patients where keyid in (select keyid from crsUniqueChildren) ;
   group by insurance ;
   into cursor crsChild
select insurance, count(*) kount from patients where keyid in (select keyid from crsUniqueAdults) ;
   group by insurance ;
   into cursor crsAdult
select *, 'C' Age from crsChild ;
   union ;
select *, 'A' Age from crsAdult ;
   order by 1 ;
   into cursor crsKounts
Mark McCasland
Midlothian, TX USA
Previous
Reply
Map
View

Click here to load this message in the networking platform