Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

TSQL how to get IDs that visit X amount of location within X amount of time?

T-Sql question, i been trying to find the best solution for this one.

Say we have this theoritical table

-----------------------------------

ID | DATETIME | Location

11 | 1/27 3:30pm | a

11 | 1/27 3:31pm | b

11 | 1/27 3:32pm | c

22 | 2/14 1:10pm | g

22 | 2/14 1:12pm | i

22 | 2/15 5:48pm | w

55 | 3/18 8:48pm | d

55 | 3/18 9:48pm | e

---------------------------

I want to create a query that return IDs that been to 2 or more different location in 5 minutes. In this case if you look at the table, ID: 11 and 22 visits 2 or more different location within 5 minutes.How do I develop a query that returns the IDs that been to X amount of location within X amount of time?

1 Answer

Relevance
  • Chris
    Lv 7
    3 years ago

    I guess the key is to look for the opposite: exclude all IDs where the shortest time in between two visits is greater than X.

Still have questions? Get your answers by asking now.