我试图除以2计数以返回一个百分比。
返回以下查询0:
0
select ( (select COUNT(*) from saxref..AuthCycle where endOfUse is null and addDate >= '1/1/2014') / (select COUNT(*) from saxref..AuthCycle where addDate >= '1/1/2014') ) as Percentage
我应该应聘演员吗?
我会用两个sums来做不同的事情:
sum
select sum ( case when endOfUse is null and addDate >= '1/1/2014' then 1 else 0 end ) * 100.0 -- if you want the usual 0..100 range for percentages / sum ( case when addDate >= '1/1/2014' then 1 else 0 end ) percentage from saxref..AuthCycle