select *,(select count(*) as groupnull,count(*)/(select count(*) from tbclient) as proportion from tbclient where groupID = bclientgroup.groupID) from bclientgroup
select *,(select count(*) as groupnull, count(*)/(select count(*) from tbclient) as proportion from tbclient where tbclient.groupID = bclientgroup.groupID) from bclientgroup
select a.groupID,a.groupname ,groupnull=count(b.clientID) ,proportion=case (select count(*) from tbclient) when 0 then '0%' else cast(cast( count(b.clientID)*100.0 /(select count(*) from tbclient) as decimal(10,2)) as varchar)+'%' end from tbclientgroup a left join tbclient on a.groupID=b.groupID group by a.groupID,a.groupname
from tbclient where groupID = bclientgroup.groupID)
from bclientgroup
select *,(select count(*) as groupnull,
count(*)/(select count(*) from tbclient) as proportion
from tbclient
where tbclient.groupID = bclientgroup.groupID)
from bclientgroup
,groupnull=count(b.clientID)
,proportion=case (select count(*) from tbclient)
when 0 then '0%'
else cast(cast(
count(b.clientID)*100.0
/(select count(*) from tbclient)
as decimal(10,2)) as varchar)+'%' end
from tbclientgroup a
left join tbclient on a.groupID=b.groupID
group by a.groupID,a.groupname