select code,name,money from a,b where a.code(+) =b.code
解决方案 »
- LINUX AS5安装ORALCE 9I时报Font specified in font.properties not found [-b&h-lucidaty
- 数据出问题了,急
- 多条记录 数据集合到一条记录
- 触发器报错
- 请问Oracle 9i 中有没有判断内容为非数字的判断函数吗?!
- oracle中的特殊字符处理问题????????
- 各位大哥,这次是真地急了!帮帮忙啊
- 输出字符串问题
- ORA-01652: unable to extend temp segment by 128 in tablespace TEMP
- 请问有知道sqlldr的用法吗?
- oracle数据库启动问题!!!急急急!
- 升星,散分!!
b表的所有项都显示出来,不符合条件的字段为空
a:code money
1 10
2 20
2 30
4 50
4 60
我想按照code分组求sum(money),(select b.code,name,sum(money) from a,b where a.code(+)=b.code group by b.code,name) 这样写好像还是不能列出code=3的列,不知道该怎么写,谢谢!
from (select code,sum(money) money from aa group by code) c,b
where c.code(+) = b.code
外部联接"+"的用法 外部联接"+"按其在"="的左边或右边分左联接和右联接.若不带"+"运算符的表中的一个行不直接匹配于带"+"预算符的表中的任何行,则前者的行与后者中的一个空行相匹配并被返回.若二者均不带’+’,则二者中无法匹配的均被返回.利用外部联接"+",可以替代效率十分低下的 not in 运算,大大提高运行速度.例如,下面这条命令执行起来很慢 select a.empno from emp a where a.empno not in (select empno from emp1 where job=’SALE’); 倘若利用外部联接,改写命令如下: select a.empno from emp a ,emp1 b where a.empno=b.empno(+) and b.empno is null and b.job=’SALE’; 可以发现,运行速度明显提高.
a:code money
1 10
1 20
2 20
4 50
6 80
b:code name kind
1 a 1
2 b 1
3 c 1
4 d 2
5 e 2
6 f 2想列出b表中kind=1的所有code的项,和求sum(money)
想象的结果为下:
code name sum(money)
1 a 30
2 b 20
3 c
应该怎么写,谢谢!(select b.code,name,sum(money) from a,b where a.code(+)=b.code and kind='1' group by b.code,name) 这样写还是不能列出code=3的项
from (select code,sum(money) money from aa group by code) c,b
where c.code(+) =bb.code and b.kind=1
2 from (select code,sum(money) money from aa group by code) c,bb
3 where c.code(+) =bb.code and bb.kind='1';CODE NAME MONEY
---------- ---------- ----------
1 a 30
2 b 20
3 c怎么会不行呢?这里aa就是你的a,bb就是你的b
2 from aa,bb
3 where aa.code(+)=bb.code and kind='1'
4 group by bb.code,name;CODE NAME SUM(MONEY)
---------- ---------- ----------
1 a 30
2 b 20
3 c