select b.username,sum(case when yn=1 then 1 else 0 end) as 通过审核,count(yn) as 总共发表,cast(cast(sum(case when yn=1 then 1 else 0 end) as decimal(18,2))/cast(count(yn) as decimal(18,2)) as decimal(18,2)) as 通过率
from Article a
inner join myuser b on a.userid=b.id
group by b.username
order by cast(cast(sum(case when yn=1 then 1 else 0 end) as decimal(18,2))/cast(count(yn) as decimal(18,2)) as decimal(18,2)) desc
[/Quote]
select b.username,sum(case when yn=1 then 1 else 0 end) as 通过审核,count(yn) as 总共发表,cast(cast(sum(case when yn=1 then 1 else 0 end) as decimal(18,2))/cast(count(yn) as decimal(18,2)) as decimal(18,2)) as 通过率
from Article a
inner join myuser b on a.userid=b.id
group by b.username
order by cast(cast(sum(case when yn=1 then 1 else 0 end) as decimal(18,2))/cast(count(yn) as decimal(18,2)) as decimal(18,2)) desc