I would like to do a simple sum per salesid in php - mysql after cross calculation between date (2 tables) to get the real time commission, all the value already come out correctly but I have a problem with the final sum per sales id.
Every time there is a change in the input commission form, the new value is inserted:
salesid commission datefrom - dateto aa0001 20% 2010/01/01 - 2010/02/09 aa0001 25% 2010/02/09 - null
and table transaction got
items qty price salesid transactiondate
call value of the table commission where salesid=$_sessionid $today = date in php next week.
if ($dateto == 0) {
$dateto = $today; }
call value of the table transaction where salesid=$_sessionid
I use below range to get the commssion with transaction date:
if ($transactiondate >= $datefrom and $transactiondate < $dateto) {
$subcommission = ($price * $commission) }
and the value come like below:
salesid commission aa0001 1000 bb0001 500 aa0001 200 bb0001 50
I already try with few sample in this web but still cannot meet the correct result. I cannot do the sum in mysql because of some reason (need calculation with other table)
the result will be:
aa0001 1200 bb0001 550
I appreciate any help to complete the test. Thank you so much.