Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Counting records using select-sql
Message
De
26/08/2004 05:53:24
 
 
À
26/08/2004 05:11:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00936513
Message ID:
00936524
Vues:
23
Try something like this:
CREATE CURSOR temp(status I)
RAND(1)
FOR lni = 1 TO 1000
	INSERT INTO temp VALUES( INT( RAND( ) * 3 + 1 ) )
NEXT

SELECT SUM( IIF( status = 1, 1, 0 ) ) as st1 ,;
       SUM( IIF( status = 2, 1, 0 ) ) as st2 ,;
       SUM( IIF( status = 3, 1, 0 ) ) as st3  ;
   FROM temp ;
   INTO CURSOR cfini
>i have table with field status with values 1,2,3. i would like to count the # of records having the status 1, 2 and 3 and then put this in a cursor.
>
>how will i be able to do this using SELECT-SQL? i thought of doing this,
>
>
>select count(*) from mytable where status=1 into cursor csr1
>
>select count(*) from mytable where status=2 into cursor csr2
>
>select count(*) from mytable where status=3 into cursor csr3
>
>select a.*, b.*, c.* from csr1 a, csr2 b, csr3 c into cursor csr4
>
>
>
>is this the best solution?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform