Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL , counting a range.
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00561221
Message ID:
00561240
Views:
26
A two steps solution:

Step 1.
SELECT IIF(BETWEEN(salary,0.00,9999.99),'r1', ;
       IIF(BETWEEN(salary,10000.00,19999.99),'r2', ;
       'r3')) as range, ;
       sex ;
       FROM yourTable ;
       INTO CURSOR Q1
or
SELECT INT(salary/10000) as range, ;
       sex ;
       FROM yourTable ;
       INTO CURSOR Q1
or, write a UDF to get the range
SELECT UserDefinedFunction(salary) as range, ;
       sex ;
       FROM yourTable ;
       INTO CURSOR Q1
Step 2.
SELECT range, sex, count(*) ;
       FROM Q1 ;
       ORDER BY 2,1 ;
       GROUP BY 2,1 ;
       INTO CURSOR Q2
Doru
Previous
Reply
Map
View

Click here to load this message in the networking platform