统计问题 select a.code,count(*)from a,bwhere a.id = b.aidgroup a.code 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select a.code,count(*) from a,b where a.id=b.aid group by a.code select code,sum(aid) from a inner join b on b.id=a.id group by id,code select a.code, count(*) as [count]from a aleft join b bon a.id=b.aidgroup by a.code to xluzhong(打麻将一缺三,咋办?)没有C 统计结果却是1....... select a.code, sum(case when b.aid is null then 0 else 1 end) as [Count]from a aleft join b bon a.id=b.aidgroup by a.code select a.code,sum( case cast(a.id as varchar) when b.aid then 1 else 0 end) from a,b group by a.code這才對了﹗﹗哈哈﹗﹗ select a.code,sum( case cast(a.id as varchar) when b.aid then 1 else 0 end) as [count] from a,b group by a.code 這樣就和你想要的結果一樣了﹗﹗ select a.code, sum(case when b.aid is null then 0 else 1 end) as bfrom a left join b on a.id=b.aidgroup by a.code to Hopewell_Go(一定好起來) 还是不一样,你自己测一下吧 100分!修改一个存储过程! sql 数据内容归类 money字段类型的显示问题,谢谢~ 如何将SQLSERVER中的binary类型转换为int类型 如何通过程序设置和读取同时登录某一数据库的的最大连接数 请问一个关于时间的小问题!!! 如何查询按月生成的表 sql server 日期转换为周的格式,请帮忙 不用游标如何进行数据库的查询? 关于Distinct 和Order By 视图的问题 sql语句求助
count(*) as [count]
from a a
left join b b
on a.id=b.aid
group by a.code
sum(case when b.aid is null then 0 else 1 end) as [Count]
from a a
left join b b
on a.id=b.aid
group by a.code
from a,b group by a.code
這才對了﹗﹗
哈哈﹗﹗
這樣就和你想要的結果一樣了﹗﹗
sum(case when b.aid is null then 0 else 1 end) as b
from a
left join b
on a.id=b.aid
group by a.code
还是不一样,你自己测一下吧