Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unique counts - subtotals
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Divers
Thread ID:
00455221
Message ID:
00456349
Vues:
21
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform