The count function will give you the list of the users (frequently visited users) and you can use the where clause to find the users in certain time period. The max function if clubbed with count will give you the top user.
hi,I have try to use count to get the users (sql: select count(“uid”) from measurement and time > now() - 1h group by time(1h) ), but failed.
With this example ,I want to get the result like
user count
userA 3
userB 1
userC 1
but the count function just get the result
time count
1502242645775000000 5
It can not get the users list
Could you show me the sql with this example ? Or the grammar of my sql is wrong ?
hi
It will panic when execute the sql ,error info below
[I] 2017-08-11T01:24:40Z SELECT top(count, source, 10) FROM (SELECT count(uid) FROM spider.autogen.app WHERE time > now() - 1h GROUP BY time(1h)) service=query
panic: runtime error: index out of range
The info of panic is from version 1.2.I have upgrade to 1.3.2. Now the sql work normally.But the result may be wrong.
From the start,I insert 5 points into measurement called t, every point has tag p and s, and field uid, like
select * from t
name: t
time p s uid
---- - - ---
1502419072967540554 pv yzl usera
1502419075188749394 pv yzl userb
1502419078856887159 pv yzl usera
1502419080484044059 pv yzl userc
1502419190701236366 open yzl userc
Second,I use the sql you give me
select top(count, p, 1) from (select count("uid") from t where time > now() - 1h group by time(1h))
name: t
time top p
---- --- -
1502416800000000000 4
or
select top(count, s, 1) from (select count("uid") from t where time > now() - 1h group by time(1h))
name: t
time top s
---- --- -
1502416800000000000 5
But I just want the users list who visit frequently ,like
I don’t this it can be achieved with this schema. You need to move this userid field as a “tag” value. Since the grouping option is only available via that