I have table of expenses:
Expense(amount: Double, vendorId: Int, vendorType: Int)
I want to create a mysql query that will give me the percentage of each vendor type with certain vendor, like:
vendorId vendorType percentOfExpencesOfThisType totalExpenses
so lets say I have 4 expences:
Expense(amount: 30.0, vendorId: 3, vendorType: 1)
Expense(amount: 58.5, vendorId: 3, vendorType: 1)
Expense(amount: 47.0, vendorId: 3, vendorType: 7)
Expense(amount: 21.5, vendorId: 3, vendorType: 13)
so the table will look:
vendorId vendorType percentOfExpencesOfThisType totalExpenses
3 1 50 4
3 7 25 4
3 13 25 4
how would I do that? (unfortunately using mysql version 5.6)