How to calculate percentage between two numbers using SQL on BigQuery?
BigQuery Calculating Percent Overlap Between Values Multiple Columns
How to compute percentages in BigQuery SQL for SUM?
BigQuery - How to calculate percentage change row by row?
calculate percentage from BigQuery table Standard SQL
calculating percentage of two columns in SQL - using BigQuery
COUNT(*) AS clearance_status_count,
(SUM(COUNT(*)) OVER(PARTITION BY primary_type)) AS total,
COUNT(*) / (SUM(COUNT(*)) OVER(PARTITION BY primary_type)) AS ratio
This query works across the different
primary_types. I included the count and the total to show that the ratio is correct.
Similar question here: Calculate percentage of group using GROUP BY