Home > database > Requirement description, please provide 60 seconds, the same user record data appear 5 times or more
Requirement description, please provide 60 seconds, the same user record data appear 5 times or more
Time:09-23
A data table, about 100 w records, field: phone number, product ID, date 13:22:42 (2018-01-01), the other Now given the two input: 1. The time range, such as: 60 seconds2. A record number of X times, such as: five
Requirement description, please provide 60 seconds, the same user record data appear 5 times or more,
Pray god to save!!!!!!
CodePudding user response:
Don't know if this meaning, you give it a try, The SET @ d:=60; - 60 seconds The SET @ c:=5; Five - SELECT T. a phone number, T. product ID, T. date The FROM (SELECT T. *, (SELECT COUNT (0) The FROM Table_name t1 . WHERE the t1 date BETWEEN t. date AND DATE_ADD (t. date, INTERVAL + @ d SECOND) AND t1. Phone number AND t cell number AND t1. The product ID=t. The product ID - if a phone number, can be on behalf of a user, please remove the this line, C) The FROM Table_name t) tc & gt;=@ c;