Search code examples
sqldivision

SQL select distinct count division


I have a select statement with a distinct count and I need to divide the result of the select count with a number . How can I do it? I have for example:

select distinct count(profile_entity_name)
from table_name
where visit_id like 'JWM%' and profile_entity_name not in ('JWM 2.0 COM','JWM 2.0 MASTER') 

and it gives the result 2000 I want to divide the 2000 with 130 for example on the fly

How can I do it? I tried the whole select with the division at the end '/130' and it doesn't work


Solution

  • As an complement to Md. Suman Kabir's Answer, if you want the select to return the exact division, just cast the "count" function and the divisor number as float, like this:

        select cast(count(distinct profile_entity_name) as float) / cast(130 as float) from table_name