1
asxalex 2015-09-20 17:27:27 +08:00 1
select tmp.username, count (1 ) cnt from (select username, count (1 ) from table_name group by username, hwid ) tmp group by tmp.username order by cnt desc;
|
2
ttcool 2015-09-20 17:33:38 +08:00 1
select tab.username,count (tab.hwid ) from (select username,hwid from test group by hwid ) tab group by tab.username;
|
3
cxbig 2015-09-20 17:40:33 +08:00 1
没有楼上没那么复杂吧
SELECT username, count (hwid ) FROM table GROUP BY username |
4
SilentDepth 2015-09-20 18:11:37 +08:00 1
@cxbig 同感。再加个 ORDER BY 就更好了
|
5
coosir 2015-09-20 18:17:31 +08:00 1
@cxbig @SilentDepth 额,这样子同终端的多次登录都会 count 进去呀
|
6
liprais 2015-09-20 18:56:41 +08:00
伸手党可耻
|
7
echo1937 2015-09-20 19:16:35 +08:00 1
MySQL 的写法. |
8
soulgeek 2015-09-20 19:23:21 +08:00 1
3 楼的 count 加个 distinct 就好了
|
9
cxbig 2015-09-20 19:55:20 +08:00 1
了解了,用 time 来做 count
SELECT DISTINCT username, hwid, count ($time ) FROM table GROUP BY username, hwid |
10
SilentDepth 2015-09-20 20:31:58 +08:00 2
|
11
cxbig 2015-09-20 20:34:40 +08:00 1
@SilentDepth 楼上正解,我记错了
|
12
SilentDepth 2015-09-20 20:39:54 +08:00 1
@cxbig 左括号前加空格可以理解,为什么右括号前也要加……什么时候回复可以支持代码展示啊 :sigh:
|
13
cxbig 2015-09-20 21:42:37 +08:00
@SilentDepth 自动给的,我没有办法。 T-T
|