Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using count() in SQL Select
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00872467
Message ID:
00872472
Vues:
28
Dmitry,
SELECT EMPLOYEE, ;
          SUM( IIF(type="A",1,0)) AS cnt_a, ;
          SUM( IIF(type="B",1,0)) AS cnt_b ;
FROM mytable ;
GROUP BY 1
>I need help, please, in determining how to do the following (simplified):
>
>Table:
>
>
>TYPE	ORDER_NO	EMPLOYEE
>A	1         JOHN
>B	2         PAUL
>B	1         GEORGE
>B	4         PAUL
>A	1         GEORGE
>B	2         GEORGE
>B         2         GEORGE
>
>
>I want summarize the above table (using SQL Select) into the following cursor:
>
>
>EMPLOYEE     NUMBER OF A ORDERS    NUMBER OF B ORDERS
>JOHN         1
>PAUL         0                     2
>GEORGE       1                     2
>
>
>When there was no TYPE field, it was easy using:
>count( distinct( ORDER_NO ) ) as NUM_ORDS group by EMPLOYEE
>
>But with introduction of TYPE I am lost.
>
>TIA.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform