Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Filter accounts based on percent value
Message
From
26/10/2006 17:44:04
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01164810
Message ID:
01164871
Views:
10
This message has been marked as the solution to the initial question of the thread.
>Hi everybody,
>
>Using VFP8 do you think it's possible to do something like
>
>select Account, sum(balance) as Total_Balance, sum(iif(MyCond,value,0)) as MyCond_Balance from ... group by 1 having MyCond_Balance/Total_Balance > 0.1 (10 %)
>
>I also need to include percent into result.
>
>Or do you think I should better do this in 2 select statements to get all balances first and then filter based on 10% condition?
>
>Thanks in advance.

ROUND THE SUM
select Account, sum(balance) as Total_Balance, sum(iif(MyCond,value,0)) as MyCond_Balance from ... group by 1 ;
having MyCond_Balance/EVL(ROUND(Total_Balance,6),.NULL.) > 0.1 

OR 
select Account, sum(balance) as Total_Balance, sum(iif(MyCond,value,0)) as MyCond_Balance from ... group by 1 ;
having ROUND(MyCond_Balance,6)> 0.1 * ROUND(Total_Balance,6)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform