Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

oracle - PL/SQL "between x and y" does not work, if y < x. Why?

I have a PL/SQL code like:

case when column between 201203 and 201201
then other_column
end

I know that there are values in column that are 201203. So code should return some values. But it didn't until I corrected it like:

case when column between 201201 and 201203
then other_column
end

Why between keyword works like that? How it is implemented on Oracle Databases?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is ANSI SQL behavior.

 expr1 BETWEEN expr2 AND expr3

translates to

 expr2 <= expr1 AND expr1 <= expr3

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...