大家好,我想用一个decode语句去统计里个数值的总个数
这个数值为(trs_time-tran_date)*24
如果这个数值小于2,那么把统计的总个数存入 lessthan2 列中
如果这个数值大于2,那么把统计的总个数存入 greaterthan2 列中,请问这个语句怎么写啊?我想的是用
select count(decode((trs_time-tran_date)*24,<=2,1))"lessthan2",
count(decode((trs_time-tran_date)*24,>2,1))"greaterthan2"
from alm_inf
可是这样出不来啊,大家帮帮我啊
这个数值为(trs_time-tran_date)*24
如果这个数值小于2,那么把统计的总个数存入 lessthan2 列中
如果这个数值大于2,那么把统计的总个数存入 greaterthan2 列中,请问这个语句怎么写啊?我想的是用
select count(decode((trs_time-tran_date)*24,<=2,1))"lessthan2",
count(decode((trs_time-tran_date)*24,>2,1))"greaterthan2"
from alm_inf
可是这样出不来啊,大家帮帮我啊
解决方案 »
- system密码忘记了怎么办?
- 怎样从unix下的oracle8.17链接到window2000下的SqlServer2000???
- 菜鸟问题:创建表时字段名可以是变量吗?如果是,怎么做?
- 更改user1的所有表的表空间后怎样重建所有的索引?
- 如何将这条在SQL Server下的查询语句转换为Oracle的查询语句?
- 100分求救,快要下岗了,急!!!!
- 超級難題200分!!oracle發email,用html報表格式,哪個高手會啊,另UP有3分,不夠再加
- 如何在ORACLE 8.1.6中实现timestamp时间戳的功能?
- 如何用OLEDB连接Oracle
- oracle 基础查询语句问题
- oracle分组求和统计,请大虾指点
- 这2句SQL怎么写?
countdecode(sign(2-(trs_time-tran_date)*24), -1,1)) "greaterthan2"
from alm_inf
count(decode((trs_time-tran_date)*24, <=2,1))-->
count(case when (trs_time-tran_date)*24<=2 then 1 end)
count(decode(sign(2-(trs_time-tran_date)*24), 0,1)) "equal",
countdecode(sign(2-(trs_time-tran_date)*24), -1,1)) "greaterthan2"
from alm_inf
select count(case when (trs_time-tran_date)*24 <=2 then "lessthan2" else "greaterthan2" end)
from alm_inf