SELECT COUNT(*) AS customer, t.state
FROM tbl_parcel_item t
WHERE t.courier_name='Tnt'
AND t.date = '2018-03-12'
AND t.ship_status NOT IN (0,1,9,10)
GROUP BY t.state`
Based on the sql above the results would be: enter image description here How to make it get total of the result above for example : enter image description here