我现在项目中要用到Mysql和Oracle两个数据库切换,以前版本中Mysql用到了Date()函数,可是我找了关于Oracle的相关资料并没有关于Oracled的Date函数
select
date(test_time) as testTime,
count(*) as alarmTotal,
sum(case when alarm_type_id=1 then 1 else 0 end) as exceptionTotal,
sum(case when alarm_type_id=2 then 1 else 0 end) as thresholdTotal,
sum(case when alarm_type_id=3 then 1 else 0 end) as interruptTotal
from alarm_result
where 1=1 and to_char(test_time,'yyyy-MM-dd') >= '2011-07-31'
group by testTime
order by test_time desc
求大神解决一下吧 ~ 我上面贴的是Mysql中关于Date函数写法
select
date(test_time) as testTime,
count(*) as alarmTotal,
sum(case when alarm_type_id=1 then 1 else 0 end) as exceptionTotal,
sum(case when alarm_type_id=2 then 1 else 0 end) as thresholdTotal,
sum(case when alarm_type_id=3 then 1 else 0 end) as interruptTotal
from alarm_result
where 1=1 and to_char(test_time,'yyyy-MM-dd') >= '2011-07-31'
group by testTime
order by test_time desc
求大神解决一下吧 ~ 我上面贴的是Mysql中关于Date函数写法
解决方案 »
- ORA报错
- 连接数据库报错
- Oracle ORA-00972:Identification too long
- 为该监听程序提供的信息正由此计算机的其他软件使用-求解
- oracle blob 上传问题
- oracle trigger 問題
- 各位有把Oracle放到公网上,客户端通过ADSL访问的方式么??安全怎么保障??
- 更新语句必须写commit吗?
- 我在查找数据库对象中找不着创建成功的表,但是TableSpace Map里却能看到,但不能修改属性.
- Oracle-TNS:could not resolve the connect identifier specified
- 如何在多表查询的结果集中找出重复的列名
- 分组 根据最晚时间 取当中每条数据
--你这句date(test_time) as testTime 可以改为:
to_char(test_time,'yyyy-mm-dd') as testTime
http://www.w3school.com.cn/sql/func_date.asp--oracle里面想达到这个效果,to_char一下就完了
to_char(test_time,'yyyy-mm-dd') as testTime,
数据库中存的是yyyy-MM-dd hh24:mi:ss 在mySql中我可以通过date(test_time)得到yyyy-MM-ss ..Oracle !!!