SELECT 
    b.product_name,
    CAST(SUM(IF(a.step='select',1,0)*b.price) AS signed) AS amount --select即支付,因为有payment method
FROM user_client_log AS a
LEFT JOIN product_info AS b
ON a.product_id=b.product_id
GROUP BY b.product_name
HAVING CAST(SUM(IF(a.step='select',1,0)*b.price) AS signed)>0 --选择已购买的品类,有些品类可能没到select这一步
ORDER BY CAST(SUM(IF(a.step='select',1,0)*b.price) AS signed) DESC --排序
;
--需要将SUM(IF(a.step='select',1,0)*b.price) 映射为整数