I’m trying to calculate percentages after a group by query on a database.

For example - I have a dataset(D) containing 2 columns X and Y. X has only 3 possible values and Y is a number type. We have multiple rows for X and Y.

My final results needs to be what percent each value of X has (and plot it using a pie chart, fwiw).

A simple group by is relatively easy and working fine -

`Search for D:grouped by X's sum of Y Value`

I’m unable to figure out how to calculate the percent after this. I need to be able to take each of the sums of X, total it and use it to calculate percentage of each grouped item. Any input is appreciated.