多条件求和 我需要统计表中满足某条件的记录个数。希望语句是这样的:Select id, Count(a=1 and b=2),count(c=3 and d=4) from table group by iddecode函数一次只能判断一个条件啊,那上面要求的语句该怎么写哦? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select t1.a,t2.b from (select count(*) a from table group by idwhere a=1 and b=2)t1,(select count(*) bfrom table group by id where c=3 and d=4)t2 Select id, sum(case when a=1 and b=2 then 1 else 0 end),sum(case when c=3 and d=4 then 1 else 0 end)from table group by id 发错了,应该用case when 语句case when 条件1 then 结果1 when 条件2 then 结果2else 结果3end select id,sum(case when a=1 and b=2 then 1else 0 end),sum(case when c=3 and c=4 then 1else 0 end),from tablegroup by id 关于表空间 请教分组求和 oracle 查询问题 返回最近记录sql语句 一个模糊查找的问题,在线急等!!! 一个关于sql的面试题 面倒了一片人,求解 谁有www.oracle.com.cn的邀请吗呀,能不能帮我弄到一个,十分感激,谢谢! 一个奇怪的问题, 修改系统时间后,再用PLSQL developer就无法查询表. 请问一个初级问题! 如何获取oracle中存储过程的参数列表 怎么解决,重复数据合并到结果集的某一条记录中 PL/SQL多重判断问题
(select count(*) a
from table group by id
where a=1 and b=2
)t1,
(select count(*) b
from table group by id
where c=3 and d=4
)t2
sum(case when a=1 and b=2 then 1 else 0 end),
sum(case when c=3 and d=4 then 1 else 0 end)
from table group by id
case when 条件1 then 结果1
when 条件2 then 结果2
else
结果3
end
id,
sum(case
when a=1 and b=2 then 1else 0
end),
sum(case
when c=3 and c=4 then 1else 0
end),
from table
group by id