Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using count() in SQL Select
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00872467
Message ID:
00872472
Views:
26
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--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform