create tablespace test
datafile 'D:\work\oracle\product\10.2.0\oradata\orcl\test.dbf'
size 50m autoextend on next 10m maxsize unlimited
logging extent management local segment space management auto;
--创建用户名
create user test
identified by test default tablespace test
temporary tablespace temp;
--付权限
grant dba to test;
--各个分情况
select t.*, t.rowid from APP_ASSETCUSTOMINFO798 t;
select count(*) as 上月末一般 from APP_ASSETCUSTOMINFO798 t where cz_rylb='一般人员' ;
select count(*) as 上月末病残 from APP_ASSETCUSTOMINFO798 t where cz_rylb='病残';
--不行
select
(select count(b.id) from APP_ASSETCUSTOMINFO798 b where b.cz_rylb='一般人员') bbb,
(select count(c.id) from APP_ASSETCUSTOMINFO798 c where c.cz_rylb='病残') ccc
from APP_ASSETCUSTOMINFO798 a
--可以
select aaa.a ,bbb.b
from
(select count(b.id) a from APP_ASSETCUSTOMINFO798 b where b.cz_rylb='一般人员') aaa join
(select count(c.id) b from APP_ASSETCUSTOMINFO798 c where c.cz_rylb='病残') bbb
datafile 'D:\work\oracle\product\10.2.0\oradata\orcl\test.dbf'
size 50m autoextend on next 10m maxsize unlimited
logging extent management local segment space management auto;
--创建用户名
create user test
identified by test default tablespace test
temporary tablespace temp;
--付权限
grant dba to test;
--数据:
ID | CZ_RYLB |
1 | 一般人员 |
2 | 病残 |
3 | 病残 |
4 | 病残 |
5 | 一般人员 |
6 | 一般人员 |
7 | 一般人员 |
--各个分情况
select t.*, t.rowid from APP_ASSETCUSTOMINFO798 t;
select count(*) as 上月末一般 from APP_ASSETCUSTOMINFO798 t where cz_rylb='一般人员' ;
select count(*) as 上月末病残 from APP_ASSETCUSTOMINFO798 t where cz_rylb='病残';
--不行
select
(select count(b.id) from APP_ASSETCUSTOMINFO798 b where b.cz_rylb='一般人员') bbb,
(select count(c.id) from APP_ASSETCUSTOMINFO798 c where c.cz_rylb='病残') ccc
from APP_ASSETCUSTOMINFO798 a
--可以
select aaa.a ,bbb.b
from
(select count(b.id) a from APP_ASSETCUSTOMINFO798 b where b.cz_rylb='一般人员') aaa join
(select count(c.id) b from APP_ASSETCUSTOMINFO798 c where c.cz_rylb='病残') bbb
on 1=1