Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What's wrong with the SQL command?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00105193
Message ID:
00105200
Views:
36
>I've got a SQL command that looks like it's working, but I noticed all the of "NumRo" values are multiples of 3. I just know this can't be right. What is it actually doing?
>
>SELECT v_tmpart.Insurance,;
> v_tmpart.range,;
> SUM(v_tmpart.subtotal) AS TotalValue,;
> COUNT(v_tmpart.ro) AS NumRo,;
> SUM(v_tmpart.numdays) AS TotalDays,;
> SUM(v_tmpart.numdays) / COUNT(v_tmpart.ro) AS AvgTime;
> FROM v_tmpart;
> WHERE v_tmpart.datein >= ?THIS.dFromDate AND v_tmpart.datein <= ?THIS.dToDate;
> GROUP BY v_tmpart.insurance,v_tmpart.range;
> INTO CURSOR ArtReport

The COUNT(v_tmpart.ro) will not give the expected result if you have null values. Try COUNT(*). Also, you can simplify the AvgTime column to be AVG(v_tmpart.numdays). HTH
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform