Jump to content

Help With Mysql Query


Recommended Posts

The table has a list of payments received including fields `type` and `amount`. My mysql query is:SELECT `type`, SUM(`amount`) AS `amount` FROM `payments` GROUP BY `type` ORDER BY `amount` DESC;which I can use to create an output like thisCash - £250.00Cheque - £125.00Other - £35.50etcI'd like to include the percentage that each type contributes towards the total. In the example above the total is 410.50 so cash will be 60.9%, cheque will be 30.5% and other will be 8.6%. Can this be done in one query?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...