Answer the question
In order to leave comments, you need to log in
How to remove subqueries in BETWEEN in SQL?
Yes, it means that my SELECT is quite loaded. I would like to make it easier, at least by removing subqueries. What I'm scratching my head about the most is the subqueries in BETWEEN. Now the part with BETWEEN looks like this:
...
SELECT * FROM Visitors v
WHERE v.last_visit_time BETWEEN
(SELECT start_time FROM Event WHERE event_id = @first_event) AND
(SELECT start_time FROM Event WHERE event_id = @second_event) AND
...
...
AND g.place_id IN (SELECT place_id FROM Event WHERE event_id = @first_event)
...
Answer the question
In order to leave comments, you need to log in
And what prevents you from getting the necessary values in advance start_time
in the same place where the variables @first_event
and are set @second_event
? With place_id
it is not entirely clear how many events can be with one event_id
? If only one - then also receive in advance.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question