|
|
|
sql and php มีตารางที่ต้องการ ออก รายงาน คือ tmpreport มี feild คือ tmpid,buy,sell,net,custaccid, |
|
|
|
|
|
|
|
มีตารางที่ต้องการ ออก รายงาน คือ tmpreport มี feild คือ tmpid,buy,sell,net,custaccid,mktid,fundunitid
เวลา ใช้คำสั่ง se;ect เพื่อ sum
$sql = "SELECT tmpreport.custaccid, tmpreport.mktid,concat(customer.firstname,'', customer.lastname) as cusname, concat(marketing.firstname,' ', marketing.lastname) as mktname, sum(tmpreport.net),sum(tmpreport.net)*100/ $sumall, team.teamname FROM (team INNER JOIN (tmpreport INNER JOIN marketing ON tmpreport.mktid = marketing.mktid) ON team.teamid = marketing.teamid) INNER JOIN customer ON (tmpreport.custaccid = customer.custaccid) AND (marketing.mktid = customer.mktid)";
if($fundunitid != 'NONE') $sql .= " AND tmpreport .fundunitid = $fundunitid ";
$sql .= " group by tmpreport.custaccid";
// group customer from transaction tables
$sql .= " order by 5 desc ";
แล้วมันดันแสดงค่ามาไม่ครบค่ะ ถ้า field fundunitid and mktid มีค่าที่ ซ้ำกันมันจะออกค่าที่ล่าสุดออกมา คือ tmpid ล่าสุดออกมา
ต้องแก้ยังไงดี
Tag : - - - -
|
|
|
|
|
|
Date :
28 ส.ค. 2550 11:48:39 |
By :
เง้เง้ |
View :
1560 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
งง มากมาย ไม่เข้าใจอ่ะนะ
|
|
|
|
|
Date :
28 ส.ค. 2550 11:54:35 |
By :
เห่อ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|