select *
,(select count(*) from tbclient where groupID = tbclientgroup.tbclientgroup)
,(select count(*) from tbclient where groupID = tbclientgroup.tbclientgroup)
/
(select count(*) from tbclient)
from tbclientgroup
,(select count(*) from tbclient where groupID = tbclientgroup.tbclientgroup)
,(select count(*) from tbclient where groupID = tbclientgroup.tbclientgroup)
/
(select count(*) from tbclient)
from tbclientgroup
解决方案 »
- sqlserver2008如何更改存储过程的所有者
- 多表关联update的问题
- sqlserver跨局域网连接问题!急!!!!!!!!!!
- 一个在我看来很怪异的查询问题!
- win2000 server下如何重装SQLServer2000,需要先进行卸载吗?
- 机器先装了linux后又还原为98,再装2000就总提示0000001xxx等错说硬件有问题或设置
- 自编一基于数据库的软件(按DAO方式),给用户试用后,出现了有的人可以正常使用,而有的人在开启程序的时候系统就提示“无法对DAO/JET D
- 菜鸟问题,有关数据库恢复
- 请教一个SQL
- 数据库账号被锁,如何解锁????
- 求助于各位,触发器。
- 登陆问题
,(select count(*) from tbclient where groupID = tbclientgroup.tbclientgroup)
,100 * (select count(*) from tbclient where groupID = tbclientgroup.tbclientgroup)
/
(select count(*) from tbclient)
,'%'
from tbclientgroup
b.groupid,a.groupname,
count(case when c.clientid then 1 else 0 end),
(count(case when c.clientid then 1 else 0 end))/count(c.*) as proportion
from tbclient a,tbclientgroup b ,tbbacklink c
where a.groupid=b.groupid and a.clientid=c.clientid
group by b.groupid,a.groupname
给点个人意见:
表 tbclient 结构如下:clientID(主) groupID(不能为空) groupname(不能为空)...表tbclientgroup 结构:groupID(主) groupname
1 合作伙伴
2 竞争对手
3 未分类
4 关系客户
这两个表中,如果groupid 与groupname都是tbclicentgroup中相应字段的话,
tbclient 中的groupname就显得重复没有必要.
,groupnull=count(b.BackLinkID)
,proportion=case
when (select count(*) from tbBackLink)=0 or count(b.BackLinkID)=0
then '0%'
else cast(cast(
count(b.BackLinkID)*100.0
/(select count(*) from tbBackLink)
as decimal(10,2)) as varchar)+'%' end
from tbclientgroup a
left join tbBackLink b on a.ClientID=b.ClientID
group by a.groupID,a.groupname