I'm trying to make a query - (CASE - WHEN statement):
--all cols are numbers
case when round((O.POCET - O.P_DEL - O.P_DEL_DOD - O.P_FAK - O.P_VYD - O.P_OBJ)/SK.VELKE_BAL,3)
between 0.66 and 0.99 then 1
when round((O.POCET - O.P_DEL - O.P_DEL_DOD - O.P_FAK - O.P_VYD - O.P_OBJ)/SK.DOD_BAL,3)
between 0.66 and 0.99 then 2
else 0 end
It's working fine, but i need to get numbers between 1.66-1.99, 2.66-2.99 and so on...
IF i use LIKE
, i can get the fraction, but not between theese numbers.
How can i solve this ?
CodePudding user response:
If you just want it when the decimal part of the (positive) number is between a range then use the MOD
function:
CASE
WHEN MOD(your_sum1, 1) BETWEEN 0.66 AND 0.99
THEN 1
WHEN MOD(your_sum2, 1) BETWEEN 0.66 AND 0.99
THEN 2
ELSE 0
END
db<>fiddle here