Answer the question
In order to leave comments, you need to log in
SQL multiple conditions when fetching how to do?
Hello!
Please advise how to make a tricky selection.
It is necessary to select all rows from the table if they fall within a certain time interval:
select everything except gmt=13, if the subscriber is now from 9 am to 11 pm, and if on the server where the selection is made, the time is from 3 pm to 6 pm , then we output gmt=13, we don't output the line with gmt=13 otherwise.
It was done like this, but without gmt=13
SELECT *
FROM [oktell].[dbo].[vm_potok]
WHERE data <= DATEADD(mi, -255, GETDATE())
AND
DATENAME(hour, DATEADD(hh, -7 + [gmt_client], GETDATE())) >= 9
AND
DATENAME(hour, DATEADD(hh, -7 + [gmt_client], GETDATE())) < 23
)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question