D
D
DESTRRR2021-09-16 17:45:44
SQL Server
DESTRRR, 2021-09-16 17:45:44

How to choose the required DateTime?

How to select one table (A) id, where Datetime will be taken from another table (B) in between.
Between DatetimeB and DatetimeB -10 hours.

Select A.id
  From Accounts A
    join Boo B on A.id =  B.id and A.datetime between B.datetime -'10:00' and B.datetime

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2021-09-16
@DESTRRR

SELECT Accounts.id
  FROM Accounts
    INNER JOIN Boo ON Accounts.id = Boo.id
  WHERE Accounts.[datetime] BETWEEN DATEADD(hh, -10, Boo.[datetime]) AND Boo.[datetime]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question