| | |
How to get the percentage..??
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2005
Posts: 5
Reputation:
Solved Threads: 0
I am doing an SQL statement that tries to get the percentage..but i dont know how to do it in MySQL
here is the sample of my code:
SELECT count( * ) , rating, percentage....
FROM `acne_prod_rating`
WHERE prod_id =5
GROUP BY rating
the output should be like this:
count(*) rating percentage
7 1 70%
2 2 20%
1 3 10%
rating legend : ( this means..user rates the product)
1 = highly recommended , got 7 votes
2 = average , got 2 votes
3 = bad , got 1 vote
I know I can do it on client code, but I'd like in sql easy and faster
here is the sample of my code:
SELECT count( * ) , rating, percentage....
FROM `acne_prod_rating`
WHERE prod_id =5
GROUP BY rating
the output should be like this:
count(*) rating percentage
7 1 70%
2 2 20%
1 3 10%
rating legend : ( this means..user rates the product)
1 = highly recommended , got 7 votes
2 = average , got 2 votes
3 = bad , got 1 vote
I know I can do it on client code, but I'd like in sql easy and faster
![]() |
Similar Threads
- Image Comparison Application using ASP.net?..Result in Percentage Format?..!! (ASP.NET)
- word counter, frequency, percentage (Java)
- Keyword Search and return match percentage (ASP)
- Format Number as percentage. (PHP)
- percentage (C++)
- Novell (Novell)
Other Threads in the MySQL Forum
- Previous Thread: secure access to customer portal page?
- Next Thread: Problem writing to DB can someone take a look at my query string??
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design developer distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire laptop law legal license licensing linux maintenance managing mariadb matchingcolumns micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization





