I have a query that returns the following structure:
start_date | pid | uid | type | total
2019-11-10 | 2006933595591018006 | 1812803885757105697 | recommended | 9
2019-11-10 | 2006933595591018006 | 1812803885757105697 | actual | 3
Now I'd love to get a ratio of totals, ratio
, between something that is type = actual
/type = recommended
. There should ever only be two results for a given set, one of each type
.
Desired output:
start_date | pid | uid | ratio
2019-11-10 | 2006933595591018006 | 1812803885757105697 | 0.3333
I assume this can be done via a group by
clause and a case
select or some such? I've been incapable of achieving it thus far.