Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can I Use SQL To Report Summary Data
Message
 
To
13/11/2006 15:32:23
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01169288
Message ID:
01169305
Views:
9
>I need to create a summary cursor of a loan file. The customer would like the items grouped based on the number of employees the borrowing company has. The groupings are (0 - 9, 10 - 24, 25 - 49, 50 - 99, 100 - 249 and 250 +). Is there a way I can do this with a SQL statement?

other way
CREATE CURSOR MyRange(Fromfield INT, ToField INT)
INSERT INTO MyRange VALUES(0  , 9)
INSERT INTO MyRange VALUES(10 , 24)
INSERT INTO MyRange VALUES(25 , 49)
INSERT INTO MyRange VALUES(50 , 99)
INSERT INTO MyRange VALUES(100,249)
INSERT INTO MyRange VALUES(250, 999999)

CREATE CURSOR Loan (NumbEmpl Int)
INSERT INTO LOAN VALUES(300)
INSERT INTO LOAN VALUES(200)
INSERT INTO LOAN VALUES(55)
INSERT INTO LOAN VALUES(30)
INSERT INTO LOAN VALUES(20)
INSERT INTO LOAN VALUES(1)

INSERT INTO LOAN VALUES(305)
INSERT INTO LOAN VALUES(249)
INSERT INTO LOAN VALUES(248)
INSERT INTO LOAN VALUES(98)
INSERT INTO LOAN VALUES(50)

SELECT COUNT(*) AS NumEmpl, MyRange.FromField;
       FROM Loan;
       LEFT JOIN MyRange ON BETWEEN(Loan.NumbEmpl,MyRange.Fromfield,MyRange.Tofield);
       GROUP By MyRange.FromField;
       INTO Cursor YourCursor
       
BROWSE NORMAL
_______________________________________________________________
Testing displays the presence, not the absence of bugs.
If a software application has to be designed, it has to be designed correctly!
_______________________________________________________________
Vladimir Zografski
Systems Analyst
Previous
Reply
Map
View

Click here to load this message in the networking platform