问题如下有一张表,如下(表名就为CASH吧) ACCT SUB_ACCT MONEY
001 001_1 50
001 001_2 0
002 002_1 70
002 002_2 20
003 003_1 0
003 003_2 0问题:用SQL语句查询该CASH表,要求查出所有子账户(SUB_ACCT)金额(MONEY)都为0的主账户(ACCT)。
001 001_1 50
001 001_2 0
002 002_1 70
002 002_2 20
003 003_1 0
003 003_2 0问题:用SQL语句查询该CASH表,要求查出所有子账户(SUB_ACCT)金额(MONEY)都为0的主账户(ACCT)。
解决方案 »
- ORA-02248: 无效的 ALTER SESSION 选项
- 请教恢复oracle数据库问题
- 在32位windows2003 sp2系统+oracle9.2.0.1+8G内存
- pl/sql转义符的问题
- 高手请教! 在plsql中如何调用EXP 和IMP
- 请教,一个查询字段合并到另一结果集中,如何实现,谢谢!
- oracel8.16内存调整后的问题
- 各位大虾,我在toad里查看表或程序,只要有汉字的地方,都是问号,怎么设置阿,我的版本是8.5.3.3阿。
- oracle的安装错误,快速解决!
- oracle监听服务无法启动 1067错误
- 怎么在oracle 11新建用户,让这个用户只能访问指定的几个表。
- 关于数据库转换至archivelog模式
1.
select acct from cash group by acct having sum(money)=0
因为money不会有负值,可以这么写
2.
select distinct acct from cash a where not exists(
select 1 from cash where money<>0 and acct=a.acct)
3.
select distnct acct from (
select acct,max(money)over(partition by acct)ma,min(money)over(partition by acct)mi
from cash)
where ma=0 and mi=0
4.
select acct from(
select acct,money,
row_number()over(partition by acct order by money desc)rn
from cash)
where rn=1 and money=0
from cash
where sub_acct
in
(
select sub_acct
from cash where money=0
)
where cm=0;
from cash
where sub_acct in (
select distinct sub_acct
from cash
where money=0
);
select acct
from cash
where sub_acct in (
select distinct sub_acct
from cash
where money=0
);