This topic is locked
[SOLVED]

 Show Percentage's in a table within the Dashboard

8/2/2015 3:49:17 AM
PHPRunner General questions
G
Gibbzey author

Hi, Need some expert help
I have a grid view table on my dashboard and I have a count next to each item. I need to also have a percentage for each row which totals the total count.
See example below



If someone can help me understand how to do this, that would be great.

Sergey Kornilov admin 8/3/2015

You can do this using subqueries, dividing each column by the total of the whole table. See an example below.

G
Gibbzey author 8/4/2015



You can do this using subqueries, dividing each column by the total of the whole table. See an example below.



Hi Sergey,
Thanks for your repsonse.. I'm missing something
This is the SQL setup I had to get that screen from the first image
SELECT

MobilePhoneChoice,

COUNT(MobilePhoneChoice) AS Count

FROM master data

WHERE MobilePhoneChoice ='Phone Option 1' OR MobilePhoneChoice ='Phone Option 2' OR MobilePhoneChoice ='Phone Option 3' OR MobilePhoneChoice ='Phone Option 4' OR MobilePhoneChoice ='Phone Option 5' OR MobilePhoneChoice ='Phone Option 6'

GROUP BY MobilePhoneChoice
(Reason for the OR statement is because I didn't want to see blank data appearing)
I changed it to what you had and I still get an error what have I dont wrong. Sorry in advanced I'm still learning sql. This program has saved me so much time <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=77630&image=2&table=forumreplies' class='bbc_emoticon' alt=':)' />
SELECT

MobilePhoneChoice,

Count(MobilePhoneChoice),

100*Count(MobilePhoneChoice)/(Select Count(MobilePhoneChoice) from master data ) as percentage

from master data

group by MobilePhoneChoice
Kind Regards,
Richard

Sergey Kornilov admin 8/4/2015

You miss backticks around master data, should be master data if your database is MySQL.

G
Gibbzey author 8/4/2015



You miss backticks around master data, should be master data if your database is MySQL.


Thanks heaps, I knew it was something so easy <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=77642&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />