晕~~我得表达能力这么差??就是如何通过一个SQL语句可以将任意选择的两个月份区间的费用总和列出来,并计算出变化比率·~~
谢谢~~
谢谢~~
解决方案 »
- sql语句中的like语句中%和*的区别?
- oracle向数据库插入数据报错unique constraint (AD.PK_CA_NOTIF_TRACK) violated
- 急,如何在SQLoader导入时实现同步查询替换
- 数据库出现java.sql.SQLException: ORA-04031: 无法分配 4096 字节的共享内存 ("large pool","unknown object","sort subheap","sort key")
- Oracle的递归——简单问题
- 如何用java程序来调用PL/SQL????
- 数据库联结参数设置
- 急,这样的SQL语句怎么写?我知道sqlserver但不知道oracle
- 如何取得系统时间?拜托各位!
- (进来看看)oracle中通过create directory 创建的目录对象放在oracle的哪个部位,找得到吗?
- 急救!!!tns server name 不能解释。
- 执行脚本后无法为表空间创建inital段区是什么原因?急!
a.id, a.name, a.fy, b.fy, (b.fy-a.fy)/a.fy inc_rate
from (select id, name, sum(fy) fy
from tab
where [date range1]
group by id, name
)a,(
select id, name, sum(fy) fy
from tab
where [date range2]
group by id, name
)b
where a.id=b.id;
SQL> select * from temp1;ID NAME MONTH MONEY
-- ---------- ----- -----
1 11 1 10
2 22 1 10
3 11 2 20
4 22 2 20
5 11 3 30
6 22 3 306 rows selectedExecuted in 0.031 secondsSQL> select name,sum(decode(month,1,money,2,money,0)) "1-2",sum(decode(month,3,money,0)) "3" from temp1 group by name;NAME 1-2 3
---------- ---------- ----------
11 30 30
22 30 30Executed in 0.016 seconds
难道decode(month,1,money,2,money,3,money,4,money,5,money,6……,money,0)) ??
特别感谢三楼的~~