SUM Function in SQL

Level 239 keystrokes

SUM function calculates the total of a numeric column.

SQL code

-- SUM adds up the price values of all rows in orders (NULLs are ignored)
-- AS total names the result column total
1SELECT SUM(price) AS total FROM orders;

Output

+--------+
| total  |
+--------+
| 150.00 |
+--------+
1 row in set
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this SQL code and how often they appear.

  • ;× 1
  • (× 1
  • )× 1

More SQL examples at level 2

← SQL typing practice