Skip to content

Instantly share code, notes, and snippets.

@jeeyoungk
Created April 12, 2013 05:10
Show Gist options
  • Save jeeyoungk/5369554 to your computer and use it in GitHub Desktop.
Save jeeyoungk/5369554 to your computer and use it in GitHub Desktop.
mysql> CREATE TABLE temp (col1 INT, col2 INT, col3 INT);
Query OK, 0 rows affected (0.02 sec)
mysql>
mysql> INSERT INTO temp (col1, col2, col3) values (1,2,3);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO temp (col1, col2, col3) values (1,3,4);
Query OK, 1 row affected (0.00 sec)
mysql> select * from temp;
+------+------+------+
| col1 | col2 | col3 |
+------+------+------+
| 1 | 2 | 3 |
| 1 | 3 | 4 |
+------+------+------+
2 rows in set (0.00 sec)
mysql> select col1, col2, sum(col3) from temp group by col1;
+------+------+-----------+
| col1 | col2 | sum(col3) |
+------+------+-----------+
| 1 | 2 | 7 |
+------+------+-----------+
1 row in set (0.00 sec)
mysql>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment