Here is what my data looks like:
I would like to see a roll up of the total impressions
, total clicks
and average ctr
for a given query
. E.g.,
Except this is just an average of the ctr
column values; whereas I need a weighted average.
I think this SO answer Calculate Weighted Average in sql for duplicate items is taking me most of the way there, but since this calculation involves two metrics (ie, impressions
and clicks
), it's a bit different.