请教一个求百分比SQL的问题
SELECT
BL.title as BallotListTitle,
BL.id as BallotListID,
COUNT(BI.id) as BallotItemCount,
(COUNT(BI.id)/(
SELECT COUNT(*) FROM ballotItem
inner join ballotList on ballotItem.keyid=ballotList.id
inner join ballotKey on ballotList.keyid= ballotKey.id
where ballotKey.id=1
)) as Bpercent
FROM ballotKey BK
inner join ballotList BL on BL.keyid=BK.id
inner join ballotItem BI on BI.keyid=BL.id
where BK.id=1
group by BL.id,BL.title
order by COUNT(BI.id) DESC
请注意我最后显示为Bpercent字段的那个子查询查出来无论如何都是0,其意图就是想选百分比的
BallotListTitle BallotListID BallotItemCount Bpercent
-------------------------------------------------- ------------ --------------- -----------
小猫广告联盟 1 57 0
小花广告联盟 2 46 0
小雨广告联盟 3 18 0
今日广告联盟 4 18 0
明天广告联盟 5 8 0