一表:
Create Table test19(a VARCHAR2(2),code INTEGER);
数据:
Insert Into test19 VALUES('A',1);
Insert Into test19 VALUES('A',2);
Insert Into test19 VALUES('A',3);
Insert Into test19 VALUES('A',4);
Insert Into test19 VALUES('B',1);
Insert Into test19 VALUES('B',2);
Insert Into test19 VALUES('B',3);
Insert Into test19 VALUES('B',4);
Insert Into test19 VALUES('C',1);
Insert Into test19 VALUES('C',2);
Insert Into test19 VALUES('C',3);
Insert Into test19 VALUES('C',4);
Insert Into test19 VALUES('D',1);
Insert Into test19 VALUES('D',4);
Insert Into test19 VALUES('E',1);
Insert Into test19 VALUES('E',4);
----------------
code 1,为投入站,3为产出站(如果没有3的,4为产出站);
结果:
**,inall,outall
A 1 ,1
B 1 ,1
C 1 ,1
D 1 ,1
E 1 ,1
有没有看明白?
Create Table test19(a VARCHAR2(2),code INTEGER);
数据:
Insert Into test19 VALUES('A',1);
Insert Into test19 VALUES('A',2);
Insert Into test19 VALUES('A',3);
Insert Into test19 VALUES('A',4);
Insert Into test19 VALUES('B',1);
Insert Into test19 VALUES('B',2);
Insert Into test19 VALUES('B',3);
Insert Into test19 VALUES('B',4);
Insert Into test19 VALUES('C',1);
Insert Into test19 VALUES('C',2);
Insert Into test19 VALUES('C',3);
Insert Into test19 VALUES('C',4);
Insert Into test19 VALUES('D',1);
Insert Into test19 VALUES('D',4);
Insert Into test19 VALUES('E',1);
Insert Into test19 VALUES('E',4);
----------------
code 1,为投入站,3为产出站(如果没有3的,4为产出站);
结果:
**,inall,outall
A 1 ,1
B 1 ,1
C 1 ,1
D 1 ,1
E 1 ,1
有没有看明白?
解决方案 »
- 如何把两条sql语句联合起来显示?横向的。
- 请教 insert /*+append */ table nologging selec * from table_other 这种方式下数据库事务的控制
- create user语句在Procedure中编译通不过:(
- 9i装完后要求修改SYS和SYSTEM的密码,又不想修改应该怎么做
- 又一数据导入问题
- 求substr的用法
- 超难问题!!如何判断数据表中一条记录是新增的还是刚刚修改过的,没有时间字段
- 共享内存,数据池问题!
- 请教exp命令能导出表的部分数据吗
- 请教各位如何规划下列oracle数据库?
- 发现表中有坏块,如何检索其它未坏的数据?以及如何查看某表上的约束?
- 数据文件被删除,如何强行删除该数据文件对应的表空间
from tb a
left join (select a,',1' outall from tb where inall='3' or inall='4')b
on a.a=b.a
where a.inall='1';
sum(decode(code,1,1,0)) as inall,
decode(sum(decode(code,4,1,3,1,0)),0,0,1) as outall,
from test19 group by a;
(
select a, sum(decode(code,1,1,0)) inall, sum(decode(code,3,1,0)) outall3, sum(decode(code,4,1,0)) outall4
from test19
group by a
order by a);
select a,
sum(decode(code,1,1,0)) as inall,
decode(sum(decode(code,4,1,3,1,0)),0,0,1) as outall,
from test19
group by a;