Reviewing code and a case statement has expression <= 1.
as opposed to <= 1
I'm not sure what the purpose of the 1.
is. Any thoughts?
1.
is a NUMERIC
(or DECIMAL
) constant, while 1
is an INTEGER
constant. In some cases it is useful to specify the data type of a constant explicitly to avoid an unnecessary (or undesirable) implicit type conversion.
Consider, for example
create table t(f1 int);
insert into t values (2);
Then select 1/f1 from t
returns 0
(INTEGER
), while select 1./f1 from t
returns 0.5
(DECIMAL
).
One might assume that on the left side of the comparison in your example there is a DECIMAL
column, and explicitly specifying a DECIMAL
constant could marginally improve performance by avoiding an implicit type cast.
1.
literal as numeric(1,0) instead of integer due to the period. Perhaps that was specified in order to match the data type of the expression (a best practice). Personally, I'd specify1.0
in that case.0
after the decimal point and the fact thatdecimal
has higher datatype precedence thanint
so the constant would be implicitly cast anyway if needed would make me think that it is likely a typing error rather than deliberate.