D
D
Denis Sh.2018-03-26 18:25:29
SQL
Denis Sh., 2018-03-26 18:25:29

How to make sql query?

There is a table like:
table.jpg
You need to select records from it with the same IP and DateTime fields and a different RequestURI field for the last minute and group them by IP.
So far, there is a request that looks for records of the same time in the last minute, but does not take into account different RequestURIs.

SELECT IP, DateTime FROM UserRequests 
WHERE DateTime IN (SELECT DateTime FROM UserRequests GROUP BY DateTime HAVING COUNT(DateTime) > 1) 
AND DateTime >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MINUTE)
GROUP BY IP

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question