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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.