I am trying to calculate prevalence in sql. kind of stuck in writing the code. I want to make automative code.
I have check that I have 1453477 of sample size and numbe
You can cast by
count(...)/count(...)::numeric(6,4) or
count(...)/count(...)::numeric(6,4)
count(...)/count(...)::decimal
as two options.
Important point is apply cast to denominator or numerator part(in this case denominator), Do not apply to division as
denominator
numerator
(count(...)/count(...))::numeric(6,4) which again results an integer.
(count(...)/count(...))::numeric(6,4)