[Solved] How I solve this questions?
You have to use GROUP BY command : SELECT id_unit, COUNT(*) FROM order_amount GROUP BY id_unit; Results : id_unit COUNT(*) kg 40 m3 30 pal 30 After if you want to display for each order your script will be : SELECT m.id_order, (select count(*) from order_amount m2 where m2.id_order = m.id_order and m2.id_unit=”kg”) as num_kg, … Read more