Last active
August 29, 2015 14:22
-
-
Save StoneCypher/eadd71eece25a1f8c66d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mysql> create table ulog(userid integer, ltype integer); | |
| Query OK, 0 rows affected (0.05 sec) | |
| mysql> insert into ulog values(1,1), (1,2), (2,1), (2,3), (3,1), (4,1), (4,1), (4,1), (4,2), (4,1), (1,2); | |
| Query OK, 11 rows affected (0.01 sec) | |
| Records: 11 Duplicates: 0 Warnings: 0 | |
| mysql> select userid, ltype, count(ltype) from ulog group by userid, ltype; | |
| +--------+-------+--------------+ | |
| | userid | ltype | count(ltype) | | |
| +--------+-------+--------------+ | |
| | 1 | 1 | 1 | | |
| | 1 | 2 | 2 | | |
| | 2 | 1 | 1 | | |
| | 2 | 3 | 1 | | |
| | 3 | 1 | 1 | | |
| | 4 | 1 | 4 | | |
| | 4 | 2 | 1 | | |
| +--------+-------+--------------+ | |
| 7 rows in set (0.00 sec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment