$products= \R::getAll("SELECT * FROM product_status JOIN product ON product.status_id = product_status.id JOIN pay ON product.paysystem_id = pay.pay_id");
$query = " SELECT product.*,(SUM(pay.summa)/product.price)*100 AS 'percent' FROM product JOIN pay ON (product.paysystem_id=pay.pay_id) GROUP BY product.id ";
$pay = \R::getAll($query);
SELECT product_status.*,
product.*,
pay.*,
((SELECT SUM(pay.summa)
FROM pay
WHERE pay.pay_id = product.paysystem_id)/product.price)*100 AS 'percent'
FROM product_status
JOIN product
ON product.status_id = product_status.id
JOIN pay
ON pay.pay_id = product.paysystem_id