[英]Searched CASE Statement with Greater Than and Less Than Comparison
I have a big calculation which will give numeric values and needs to be compared for greater than and less than我有一个很大的计算,它将给出数值并且需要比较大于和小于
CASE big_expression
WHEN > 0 AND <5 THEN 'Less Than 5 Days'
WHEN > 5 AND <20 THEN 'Between 5 and 20 Days'
-
Can this be done or I need to use the expressions every time I make a comparison可以这样做吗,或者我每次进行比较时都需要使用这些表达式
You can use CTE for the same您可以将 CTE 用于相同的
WITH data
AS (SELECT 1 + 2 + 5 + 9 AS big_exp
FROM dual)
SELECT CASE
WHEN big_exp > 0
AND big_exp < 5 THEN 'Less Than 5 Days'
WHEN big_exp > 5
AND big_exp < 20 THEN 'Between 5 and 20 Days'
ELSE 'Greater than 20 days'
END
FROM data
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.