Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What's wrong with the SQL command?
Message
From
07/06/1998 10:11:31
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00105193
Message ID:
00105612
Views:
25
>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

Are you sure that
> SUM(v_tmpart.numdays) / COUNT(v_tmpart.ro) AS AvgTime;
is what you want, or rather, are you sure it will do what you want. I'm not sure you get what you expect here - calculated sum divided by calculated count. I can't pinpoint the reasons why I feel this isn't right, but there was some odd rule on combining aggregate functions in a SQL statement... try without this line.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform