I am trying to calculate a proportion of a portion to a total. My table looks like this:
State | City | Money_Awarded |
---|---|---|
NY | NYC | 5 |
NY | QBC | 7 |
NJ | NJC | 8 |
NJ | ABC | 6 |
I have written a query that gives me totals per state (using SUM and GROUP BY state), but I am having trouble returning another column that would calculate the proportion of EACH state to the total. I could write a sum query for the Money_Awarded column and then use the result, but I'd like to do this programmatically. How can I do this? I am using MySQL