mysql> SELECT SUM(*) FROM [table name];
To get the sum of a column in MySQL, you can use the SUM()
function. Here’s the basic syntax:
sql
SELECT SUM(column_name) FROM table_name;
Replace column_name
with the name of the column for which you want to calculate the sum, and table_name
with the name of the table where the column is located.
For example, if you have a table named sales
and you want to find the sum of the amount
column, the query would look like this:
sql
SELECT SUM(amount) FROM sales;
This will return the sum of all values in the specified column.