All Questions
Tagged with query-refactor query
2 questions
12
votes
3
answers
780
views
Are these two queries logically equivalent?
Are these two queries logically equivalent?
DECLARE @DateTime DATETIME = GETDATE()
Query 1
SELECT *
FROM MyTable
WHERE Datediff(DAY, LogInsertTime, @DateTime) > 7
Query 2
SELECT *
FROM ...
6
votes
3
answers
45k
views
Alternative query to this (avoid DISTINCT)
Note: I work with MSSQL 2008, but I guess it's valid for many others DB engines
I have this table "Users":
UserID User CountryID
1 user 1 1
2 user 2 2
3 user 3 3
4 user 4 ...