Here is my data table:
userid timestamp
------------------------
user1 2017-08-15 17:00
user1 2017-08-15 17:00
user1 2017-08-15 17:00
user2 2017-08-15 17:00
user2 2017-08-15 17:00
user3 2017-08-15 17:00
user1 2017-08-15 18:00
user1 2017-08-15 18:00
user2 2017-08-15 18:00
user2 2017-08-15 18:00
user2 2017-08-15 18:00
user3 2017-08-15 18:00
I want the result to look like this:
userid countoftimestamp
-----------------------------
user1 3_2017-08-15 17:00
user2 2_2017-08-15 17:00
user3 1_2017-08-15 17:00
user1 2_2017-08-15 18:00
and so on.
SELECT userid, timestamp, count(*)
FROM datatabable
GROUP BY userid, timestamp
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.