有没有办法计算百分比

Is there a way to count and calculate percentages

在这张图片中,

试试这个:

with cte_count as(
  SELECT header1 , count(header1) as total
  FROM tb_name
  group by header1
  ),

cte_sum as (

    SELECT header1, header5,count(header5) as ct
    FROM tb_name 
    group by header1, header5 
)

Select cte_sum.*, (cte_sum.ct*1.0*100 / cte_count.total) as percentage
From cte_sum left join cte_count
on cte_sum.header1 = cte_count.header1