MySQL SUM, medregn 0,25, 0,5 og 0,50 som 1..
Hej eksperterJeg har noget kode der tæller antallet af pakker i en forsendelse, men når den støder på et 0,25, 0,5 eller 0,50 skal den tælle det som 1..
Her er min kode:
function getTotalPackages($id) {
$query_get_total_packages_1 = mysql_query("SELECT COUNT(packages.package_number) AS totalPackages FROM packages WHERE packages.consignment_id = " . $id . "
AND UCASE(packages.package_type) != 'INDU'
AND UCASE(packages.package_type) != 'PL'
AND UCASE(packages.package_type) != 'STK'") or die(mysql_error());
$row_total_packages_1 = mysql_fetch_assoc($query_get_total_packages_1);
$query_get_total_packages_2 = mysql_query("SELECT SUM(packages.package_number) AS totalPackages FROM packages WHERE packages.consignment_id = " . $id . "
AND UCASE(packages.package_type) != 'CBM'
AND UCASE(packages.package_type) != 'LDM'
AND UCASE(packages.package_type) != 'KG'") or die(mysql_error());
$row_total_packages_2 = mysql_fetch_assoc($query_get_total_packages_2);
return intval($row_total_packages_1["totalPackages"]) + intval($row_total_packages_2["totalPackages"]);
}
Nogen der kan fortælle hvad jeg skal gøre? :)