Below table is my favorite result (please click on image to enlarge it) :
I have problem with calculation of weightPercent column :
In above table (20) is calculated as described below :
(200/(200+300)) * (100/200) * 100 = 20
So query should be something like :
,((orderAmount/([B]<font color='"Red"'>?</font>[/B])) * (delivered/orderAmount) * 100) AS weightPercent
Group By projectName;
t know how should I interact with ([B]<font color='"Red"'>?</font>[/B]) mark in above query ? I need to calculate that summation for every projectm looking for any other solution ;Is there any other trick for it ?
<font color='"Blue"'>P.S :</font> Above query is a abridgement of one complicated query . I tested [U]SUM(DISTINCT *)[/U] but I got many problems with it ,
what are those numbers? where do they come from?
I have placed one screenshot that shows the final result; those numbers are description of how (20) is obtained from first row of that table.That is just one example to show how table should work to calculate "weightPercent".
(200--->from orderAmount/(200+300)--->from orderAmount) * (100---->from delivered/200---->from orderAmount) * 100 = 20
, daTable.delivered * 100.0 /
subtotals.project_amount AS weightPercent
FROM ( SELECT projectName
, SUM(orderAmount) AS project_amount
BY projectName ) AS subtotals
ON daTable.projectName = subtotals.projectName
Interesting solution , TNX