Jump to content

Need Help: Weighted Sales Forcast


nostic

Recommended Posts

Hello EVERYONE!

 

I've been tasked with creating a weighted sales forcast for our sales team and I have decided to use highcharts for the graphing.  I am having some issues with the exact query I need to run and am hoping someone can help me out.

 

Here is my current query:

 

<?php
$SecurityQuery = "SELECT (sum(amount * (probability / 100))) as weighted FROM opportunities INNER JOIN users on assigned_user_id = users.id WHERE department = 'Security' and opportunities.probability != '100' and opportunities.probability != '0' group by WEEK(opportunities.date_entered)"; 

$result = mysql_query($SecurityQuery); 
?>

 

and I am filling an array to graph with

 

<?php
while($row = mysql_fetch_assoc($result)) { 
   echo  $row['weighted']. ",";
}  
?>

 

which is populating the array correctly with values suchs as [14000,22000,18000,19000], what I need though is to add each number in the array to all previous values.  So I would like the array to actually populate like so [14000,36000,54000,73000]. 

 

Can anyone point me in the right direction to do this?  I know I can actual just do it though specific sql querys where I select the data for just that week then add it to the other week and just keep going, however that seems like the long way about it and there has to be a way to do this though a while loop...or am I crazy?

 

thanks!

 

Link to comment
https://forums.phpfreaks.com/topic/250397-need-help-weighted-sales-forcast/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.