F
F
Fable23482020-02-28 17:47:03
MySQL
Fable2348, 2020-02-28 17:47:03

How to set up a selection of addresses for every hour?

TK: find unique poppy addresses in the database, from June 1 to June 12, which met more than 10 times. Code example: SELECT macvalue
FROM bigbrother.00100
WHERE DATE_FORMAT(FROM_UNIXTIME(VisitTime), '%Y-%m-%d %H:00:00') BETWEEN '2019-06-01 0:00:00' AND '2019 -06-12 23:59:59'
GROUP by macvalue
HAVING COUNT(MacValue)>10

This is incorrect because it doesn't count exactly how many times in any particular hour there were more than 10 times the same address.

Question: how to make a selection specifically by hour, for example: (more than 10 times were in the period from 12 to 13, or from 20 to 21 hours) I was told to do this using Round and Truncate, but I don’t know how

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2020-02-28
@Stalker_RED

SELECT macvalue,
count(*) as cnt -- gsom!
FROM bigbrother.00100
WHERE DATE_FORMAT(FROM_UNIXTIME(VisitTime), '%Y-%m-%d %H:00:00') BETWEEN '2019-06-01 0:00:00' AND '2019-06-12 23:59:59'
GROUP by macvalue
HAVING COUNT(MacValue)>10

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question