step1:计算加购数量和除以访问数量和;

step2: 以商品id分组;

step3:按prd_id排序。

SELECT prd_id, round(SUM(if_cart) /SUM(if_vw), 2) as cart_rate

From tb_clk_rcd

group by prd_id

ORDER by prd_id;