You just need to CROSS JOIN
the SUM()
of Number
column:
SELECT Name, Number, Number * 100 / t.s AS `% of total`
FROM mytable
CROSS JOIN (SELECT SUM(Number) AS s FROM mytable) t
More Related Contents:
- get first occurrence of last changed value of a column [closed]
- MySQL Error #1071 – Specified key was too long; max key length is 767 bytes
- multiple query same table but in different columns mysql
- How can I make SQL case sensitive string comparison on MySQL?
- Import data in MySQL from a CSV file using LOAD DATA INFILE
- How to do a batch insert in MySQL
- Get current AUTO_INCREMENT value for any table
- Creating a “Numbers Table” in MySQL
- Choosing a stand-alone full-text search server: Sphinx or SOLR? [closed]
- Determine which MySQL configuration file is being used
- INSERT INTO … SELECT FROM … ON DUPLICATE KEY UPDATE
- Rails, MySQL and Snow Leopard
- MySQL CONVERT_TZ()
- mysql trigger stored trigger is already used by statement which invoked stored trigger
- Error Dropping Database (Can’t rmdir ‘.test\’, errno: 17)
- Error Code: 1290. The MySQL server is running with the –secure-file-priv option so it cannot execute this statement
- mysql update query with sub query
- What is the difference between the backtick and the square bracket in SQL statements?
- Comma separated string of selected values in MySQL
- MySQL InnoDB: autoincrement non-primary key
- How to insert a file in MySQL database?
- What does SQL Select symbol || mean?
- Foreign key to one of many tables?
- What’s the recommended way to connect to MySQL from Go? [closed]
- What is wrong with my SQL here? #1089 – Incorrect prefix key
- MySQL. Can’t create table errno 150
- How to find all the relations between all mysql tables?
- Incorrect integer value: ” for column ‘id’ at row 1
- Inventory management with stock options
- Working with INTERVAL and CURDATE in MySQL