1
asxalex Sep 20, 2015 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 Sep 20, 2015 select tab.username,count (tab.hwid ) from (select username,hwid from test group by hwid ) tab group by tab.username;
|
3
cxbig Sep 20, 2015 没有楼上没那么复杂吧
SELECT username, count (hwid ) FROM table GROUP BY username |
4
SilentDepth Sep 20, 2015 @cxbig 同感。再加个 ORDER BY 就更好了
|
5
coosir Sep 20, 2015 @cxbig @SilentDepth 额,这样子同终端的多次登录都会 count 进去呀
|
6
F281M6Dh8DXpD1g2 Sep 20, 2015
伸手党可耻
|
7
echo1937 Sep 20, 2015 MySQL 的写法. |
8
soulgeek Sep 20, 2015 3 楼的 count 加个 distinct 就好了
|
9
cxbig Sep 20, 2015 了解了,用 time 来做 count
SELECT DISTINCT username, hwid, count ($time ) FROM table GROUP BY username, hwid |
10
SilentDepth Sep 20, 2015 |
11
cxbig Sep 20, 2015 @SilentDepth 楼上正解,我记错了
|
12
SilentDepth Sep 20, 2015 @cxbig 左括号前加空格可以理解,为什么右括号前也要加……什么时候回复可以支持代码展示啊 :sigh:
|
13
cxbig Sep 20, 2015
@SilentDepth 自动给的,我没有办法。 T-T
|