I\'m trying to divide 2 counts in order to return a percentage.
The following query is returning 0
:
select (
(select COUNT(*) from sax
It can be done more succinctly by moving the common condition to the where clause:
select sum(case when endOfUse is null then 1 end) * 100.0 / count(*) percentage
from saxref..AuthCycle
where addDate >= '1/1/2014'
Note how you don't need the case of 0
for false either, since nulls are ignored with sum()