Udemy - The Ultimate MySQL Bootcamp: Go from SQL Beginner to Expert를 수강하며 정리하는 글
SELECT SUM(칼럼명)
FROM 테이블명;
mysql> SELECT SUM(pages) FROM books;
+------------+
| SUM(pages) |
+------------+
| 6158 |
+------------+
1 row in set (0.00 sec)
mysql> SELECT author_fname, author_lname, SUM(pages)
FROM books GROUP BY author_fname, author_lname;
+--------------+----------------+------------+
| author_fname | author_lname | SUM(pages) |
+--------------+----------------+------------+
| Jhumpa | Lahiri | 489 |
| Neil | Gaiman | 512 |
| Dave | Eggers | 1293 |
| Michael | Chabon | 634 |
| Patti | Smith | 304 |
| Raymond | Carver | 702 |
| Don | DeLillo | 320 |
| John | Steinbeck | 181 |
| David | Foster Wallace | 672 |
| Dan | Harris | 256 |
| Freida | Harris | 428 |
| George | Saunders | 367 |
+--------------+----------------+------------+
12 rows in set (0.00 sec)