Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multiple sums in one select
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00612819
Message ID:
00612831
Views:
23
This message has been marked as the solution to the initial question of the thread.
I would split it in two selects. The first calculates woHours and totalHours and the second uses calculated values.

>I'm build a cursor to use for a report and need to repeat the same sum() many times. Is there a way to resuse a calculated field again?
>
>This is an example, but I have to create hours and ratios for a dozen different time types:
>
Select sum(ts.nHours) as totalHours, ;
>	Sum(IIF(ts.fk_timetype_id = 1, 1, 0)) As woHours, ;
>        ** The following is repeating the totalHours and woHours sums
>        ** is there a way resuse those calculated columns?
>	Sum(IIF(ts.fk_timetype_id = 1, 1, 0)) / (sum(ts.nHours) / 100) As woRatio
>
>TIA
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform