DROP PROCEDURE IF EXISTS `p_test`;
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `p_test`()
BEGIN
SET @countOrder := (SELECT COUNT(`id`) FROM `order_header`);
SELECT
a.`customer_name`,
COUNT(b.`id`) AS `orders`,
CONCAT(ROUND(((COUNT(b.`id`) / @countOrder) * 100),2),'%') AS `percentage`
FROM
`customer` a
LEFT JOIN
`order_header` b ON a.`id` = b.`customer_id`
GROUP BY
a.`id`
ORDER BY
a.`customer_name` ASC;
END $$
DELIMITER ;