Add "total" column as a dimension in Druid queries

Is it possible to aggregate the following dataset:

Into:

My goal is to calculate another metric based on the formula: metric_value / total which I am having troubles with doing as my query is based on groupBy (this is must have, but I can squeeze in another subquery if needed).


This is a companion discussion topic for the original entry at https://stackoverflow.com/questions/73389880/add-total-column-as-a-dimension-in-druid-queries