SELECT `a`.*, concat(a.formNo, "[", lpad(a.serialNo, 8, "0"), "]") as formNo, `b`.`customerName`, `b`.`attention`, `b`.`phoneNumber1`, sum(c.amount * a.exchangeRate) as customerTotal
FROM (`comp_delivery_order` a)
JOIN `customer` b ON `b`.`ID` = `a`.`customerID`
LEFT OUTER JOIN `comp_delivery_detail` c ON `c`.`deliveryID` = `a`.`ID`
WHERE `a`.`companyID` =  '3'
AND `a`.`deliveryOrderDate` >= '2016-02-01'
AND `a`.`deliveryOrderDate` <= '2016-02-29'
GROUP BY `a`.`customerID`
ORDER BY `a`.`companyID`, `a`.`customerID`