SELECT EMPLOYEE, type, count( distincttype + STR(ORDER_NO,10) ) as NUM_ORDS
FROM mytable
groupby EMPLOYEE, type ;
INTOCURSOR crsTemp
SELECT EMPLOYEE, SUM(IIF(type="A", NUM_ORDS,0) AS cnt_a, ...
FROM crsTemp;
groupby EMPLOYEE
>Sergey, > >Your approach will count total number of A orders and B orders. But I want to count number of UNIQUE orders. In example below George had 2 unique B orders yet he had 3 total B orders. > >Thank you. >