I have this dataset
Year score count
2007 20 grade 2000
2006 20 2385
2006 20 grade 10
2006 20 grade_N 3
2005 40 grade 428
2006 40 grade 815
2006 40 grade_1 15
2006 40 grade 3
...
Generated by
SEL years,
Score,
,count(0)
,100.0*count(0)/sum(count(*)) over () as pct
From table1
Group by 1,2
If I add a condition
Where years =2006 it gives me the right percentage
2006 20 73.8
2006 20 grade 0.0
...
But if I do not specify it, it returns lower number. How can I determine percentage by year?
Try this.
sum(count(*)) over (partition by YEAR)