0

In SQL we have these 2 function to retrieve data in range, I am using this on datetime field and trying to retrieve data for last 4 years.

Just wanted to confirm which is better in terms of query performance out of BETWEEN...AND or >= .

My final result row count is 200000 and it is has grouping, overall execution time is 3 minutes.

1 Answers1

0

Actually, there is a slight difference BETWEEN and regular operators.

BETWEEN is inclusive, meaning the expression WHERE COL BETWEEN 200 AND 500 is equivalent to writing WHERE COL >=200 AND COL < 501 (or <=)

On the other hand, the operators < and >and = are exclusive.

Its a distinction that should be kept in mind.

BETWEEN - MSDN

clifton_h
  • 1,298
  • 8
  • 10