A B
---------
A Y
A N
A Y
B Y
B Y
A N
怎么用一个查询语句分别统计两列中的数量呢。。
解决方案 »
- win7 安装oracle11g 报错
- 如何在oracle的图形界面里创建用户
- bdump文件很大,是怎么回事?
- Proc SQLCODE 编译问题!!紧急!!
- 求助关于OracleDeveloperSuite10g安装后不能使用pl/sql dev进入数据库
- 超级难题,数据库同步问题,不用导入导出
- 100分求在CLOB字段中插入2000个以上汉字异常问题。insert抛错:仅可以为插入 LONG 列的 LONG 值赋值
- 如何在oracle中插入&符号
- 很弱的问题:数据不能插入!增么办?急!!!在线等!
- 连接不在同一个地址段内的服务器
- 新建两个表主外键,索引,触发器新建针对两表的一个过程
- 请问新建oracle实例好还是新建用户方案
union all
select count(distinct B) from tablename
--例如
SQL> select count(distinct empno) from emp
2 union all
3 select count(distinct deptno) from emp;COUNT(DISTINCTEMPNO)
--------------------
14
3
select count(*) from table group by A,B
countA countB
-------------
4 4
from table_ab group by a
union
select b, count(b)
from table_ab group by b;不過a和b字段類型應該要一樣才行
(select count(*) from table where A='A') m,
(select count(*) from table where B='Y')
select SUM(decode(A,'A',1,0)) countA ,SUM(decode(B,'Y',1,0))countB
from table ;
sum(case when A='A' then 1 else 0 end) ,
sum(case when B='Y' then 1 else 0 end)
from tb
from table ;
count(case when A='A' then 1 else null end) ,
count(case when B='Y' then 1 else null end)
from tb
select (select count(*) from tb where A='A'),
(select count(*) from tb where B='Y')
from dual
select (select count(*) from tb where A='A'),
(select count(*) from tb where B='Y')
from dual
这个也
select * from (
select count(*),a from aa group by a
union
select count(*),b from aa group by b);
COUNT(*) A
---------- ----
2 B
3 N
4 Y
5 A
(select count(*) from table where A='A') m,
(select count(*) from table where B='Y')