mysql - 查询每小时内的生成订单数超过十条的用户
大家讲道理
大家讲道理 2017-04-17 14:53:29
0
2
670

有一个order的表,字段有orderID,username,create_time。如何查询出异常用户及其异常订单?

异常用户的判定:同一用户,每一小时内下单超过十个则为异常用户

注:是每个小时的噢,一个24个小时,然后一年365天,都要查出来,只有用户有一次一小时内充值下单超过十次就算异常,要查出所有异常单和异常用户

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
小葫芦

You can use mysql's group by username to perform classification and aggregation, count the summary results (orderID), and limit the create_time to within 1 hour. I don't know what field you use for create_time, whether it is an unsigned integer or a date. Time type, their definition methods are different, please search by yourself.

伊谢尔伦
select *
from order AS o
where o.create_time > DATE_SUB(now(),INTERVAL 10 MINUTE)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template