Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there a more elegant solution SQL
Message
From
02/08/2007 03:58:32
 
 
To
27/07/2007 11:44:08
Bill Drew
Independent Consultant
Chicago, Illinois, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01244138
Message ID:
01245400
Views:
23
>I'm looking to count the number of incidents various ranges of months.
>
>Can the following query be done without the second procedural step -- purely in SQL?
>
>
>*******************************
>PROCEDURE GetViosInRange
>*******************************
>LPARAMETERS tcVioCat,tnLowMonths,tnHiMonths,tnLowBound,tnHiBound
>LOCAL lnRetVal
>SELECT * FROM WCDRVA ;
>WHERE mvrcat = tcVioCat ;
>AND BETWEEN(monthsago,tnLowMonths,tnHiMonths) ;
>AND drvseq = this.drivernum;
>INTO cursor thesevios
>lnRetVal = 0
>IF tnlowbound > 0
>   SKIP tnlowbound-1
>   SCAN WHILE RECNO() <= tnhibound
>     lnretval = lnretval + 1
>   ENDSCAN
>endi
>RETURN lnRetVal
>
* VFP9
SELECT;
COUNT(*) AS counts;
FROM;
(SELECT * FROM WCDRVA ;
WHERE mvrcat = m.tcVioCat ;
AND BETWEEN(monthsago,m.tnLowMonths,m.tnHiMonths) ;
AND drvseq = m.this.drivernum) X;
WHERE RECNO() BETWEEN m.tnlowbound AND m.tnhibound;
INTO cursor RETURN
RETURN counts
Previous
Reply
Map
View

Click here to load this message in the networking platform