1
我試圖獲得查詢的1列的SUM。我希望將Ex,Est和WP匹配的Len和Stat在電纜,繩索或SubDucted中的位置合併。我的數據庫看起來如下來自查詢的列的總和
Ex Est WP Sec Len Stat TM
Sacriston IBGLEPTA WP1-WP2 7901 7 Cabled NoTM
Sacriston IBGLEPTE WP1-WP2 6182 80 Roped NoTM
Sacriston IBGLEPTE WP1-WP2 7206 156 Cabled NoTM
Sacriston IBGLEPTE WP1-WP2 7207 80 SubDucted NoTM
Sacriston IBGLEPTE WP1-WP2 7207A 130 Cabled NoTM
Sacriston IBGLEPTE WP1-WP2 7208 111 SubDucted NoTM
Sacriston IBGLEPTE WP1-WP2 7208A 116 Desilt NoTM
Sacriston IBGLEPTE WP1-WP2 7209 58 Overlay TM
Sacriston IBGLEPTE WP1-WP2 7209A 177 SubDucted NoTM
Sacriston IBGLEPTE WP1-WP2 7341 38 Cabled NoTM
Sacriston IBGLEPTE WP1-WP2 7342 189 Unproven NoTM
我查詢
$result = mysql_query("SELECT SUM(Length) AS totalm FROM btsec WHERE WP='$wpchose' AND Exchange='$exchose' AND Estimate='$jobchose'");
$row = mysql_fetch_assoc($result);
$totalm = $row['totalm'];
$result1 = mysql_query("SELECT SUM(Length) AS totalroped FROM btsec WHERE WP='$wpchose' AND Exchange='$exchose' AND Estimate='$jobchose' AND Status='Roped' OR Status='SubDucted' OR Status='Cabled'");
$row1 = mysql_fetch_assoc($result1);
$roped = $row1['totalroped'];
$ropedp = (int)(($roped/$totalm) * 100+.5);
這是給不正確的結果,我結束了的東西是11000%完成?
謝謝。這工作。我會盡快接受答案 –
歡迎您:) –