实际上是一个问题
b字段全部为null的的记录:
select id,count(b) as fcount
from table1 t1
group by id where b is null
and not exist (select b from table1 t2 where t2.id=t1.id and t2.b is not null)查a字段都为2的记录你自己想想吧。
b字段全部为null的的记录:
select id,count(b) as fcount
from table1 t1
group by id where b is null
and not exist (select b from table1 t2 where t2.id=t1.id and t2.b is not null)查a字段都为2的记录你自己想想吧。
“b字段全部为null的或者a字段都为2的记录”什么意思?
select id,count(b) as fcount
from table1 t1
where b is null
and not exist (select b from table1 t2 where t2.id=t1.id and t2.b is not null)
group by id
变量数组
来保存
SQL语句生成的记录集的变量数组多谢!!
from table1 t1
where b is null
and not exists (select b from table1 t2 where t2.id=t1.id and t2.b is not null)
group by id
这个可以
mmzxg(超级笨蛋) ,你好!
其中的b is null我看可以省略,
select id,count(b) as fcount
from table1 t1
where not exists (select b from table1 t2 where t2.id=t1.id and t2.b is not null)
group by id
这样也可以。
icevi(按钮工厂) 、Haiwer(海阔天空) 、mmzxg(超级笨蛋) 你们认为呢?
此问题回答后立即给分!
你理解错了,但我解释不清楚.
to:按钮工厂
快来,这个我解释不清楚!
这样写:
select id,count(isnull(b,'')) as fcount
from table1 t1
where not exists (select b from table1 t2 where t2.id=t1.id and t2.b is not null)
group by id 刚从洞里出来。现在还是再回去吧:(((((海兄,你自己看着办吧,55555555~~~~~~~~~~~
上面的是你的最终答案吗?
是的,我测试后好象没问题了。
select id,count(*)as fcount from test where b is null group by id
select id,count(*)as fcount from test where a=2 group by id