Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Distinct Count
Message
De
04/01/2007 18:18:30
 
 
À
03/01/2007 08:23:55
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
01181738
Message ID:
01182569
Vues:
24
I couldn't do it in one statement. Here's an alternative way of doing it in two
SELECT t1.date1,COUNT(DISTINCT t1.sno) sno,MAX(0000) icode,SUM(t1.weight) weight;
  FROM testsub t1 GROUP BY t1.date1;
UNION ALL;
SELECT t2.date1,MAX(0000),COUNT(DISTINCT t2.icode),MAX(0000);
 FROM testsub t2 GROUP BY t2.date1;
INTO CURSOR cur1

SELECT date1,SUM(sno) sno,SUM(icode) icode,SUM(weight) WEIGHT;
 FROM cur1;
 GROUP BY date1
>Dear Experts
>
>CREATE CURSOR testsub (date1 d(8),sno n(2),icode n(2),weight n(2))
>INSERT INTO testsub VALUES ({^2007/01/01},1,5,10)
>INSERT INTO testsub VALUES ({^2007/01/01},3,7,20)
>INSERT INTO testsub VALUES ({^2007/01/01},3,7,30)
>INSERT INTO testsub VALUES ({^2007/01/02},1,3,40)
>INSERT INTO testsub VALUES ({^2007/01/02},2,3,50)
>INSERT INTO testsub VALUES ({^2007/01/02},1,3,60)
>INSERT INTO testsub VALUES ({^2007/01/03},1,8,70)
>
>I want to scan
>COUNT of distinct sno,icode
>and sum of weight group by date1
>
>The query result must be as follows
>01-07-2006----2-----2----60
>02-07-2006----2-----1----150
>03-07-2006----1-----1----70
>
>Please help
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform