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 :
I don`t know how should I interact with (?) mark in above query ? I need to calculate that summation for every projectCode:SELECT projectID ,projectName ,orderAmount ,delivered ,((orderAmount/(?)) * (delivered/orderAmount) * 100) AS weightPercent Group By projectName;
P.S : Above query is a abridgement of one complicated query . I tested SUM(DISTINCT *) but I got many problems with it ,
so I`m looking for any other solution ;Is there any other trick for it ?