>I have 2 fields where I want to do a count using a sql statement. First I have a sex field which contains "m" or "f", and I have a salary field which is numeric. I want to count using ranges, such as, (0.00-9999.99) as r1,(10000.00-19999.99) as r2, (20000.00-29999.99) as r3, etc., and the sex. I would like a report that might look something like this:
>
>range----sex----count()
>r1---------f-------5
>r2---------f-------5
>r2---------f-------5
>r3---------f-------4
>r3---------f-------4
>r1---------m-------5
>r2---------m-------5
>r3---------m-------4
>
>
>TIA,
>Jim
Jim -
Try:
SELECT IIF(salary < 10000, 1, ;
IIF(salary < 20000, 2, ;
IIF(salary < 30000, 3, ;
IIF(salary < 4000, 4, 5)))) AS MyRange, sex ;
FROM MyTable ;
INTO CURSOR cTemp1
SELECT MyRange, sex, COUNT(*) AS MyCount ;
FROM ctemp1 ;
GROUP BY 1, 2 ;
INTO CURSOR cTemp2
REPORT FORM MyReport.FRX
Is this what you meant?
- George