语句转换

zhangwlkw 2012-08-20 05:35:16
SELECT cso.F_Key, cso.F_ServiceType,cso.F_ASPNode,cso.F_Productline,cso.F_InternalCloseTime,case WHEN F_InternalCloseTime>isnull(F_ComplaintTime,'1900-1-1') THEN F_InternalCloseTime
ELSE isnull(F_ComplaintTime,'1900-1-1') end MAXTime
FROM cr_cs_cso cso
left join CR_C_RewardPunishRecord rpd on rpd.f_cso = cso.f_key
left join CR_C_RewardPunishCriteria rpc on rpc.f_key = rpd.f_RewardPunishCriteria
WHERE 1=1 and rpd.f_status =50 and rpc.f_code in ('HTF01','HTF02','HTF03','HTF05','HTF06','HTF08','HTF09','HTF10','HTF13')
AND F_Priority IS NOT NULL
AND F_ComplaintType IS NOT NULL
AND F_ComplaintTime IS NOT NULL
AND (F_ComplaintType IN (4003,4006,4007,4008,4005,4009,4019,4034,4030,4029,4018) or F_Priority IN (70,60))
AND cso.F_Status in (160,170,180)
AND case WHEN F_InternalCloseTime>isnull(F_ComplaintTime,'1900-1-1') THEN F_InternalCloseTime
ELSE isnull(F_ComplaintTime,'1900-1-1') end BETWEEN '2012-06-27 00:00:00' AND '2012-07-26 23:59:59' and rpd.f_yearmonth='2012-07'
ORACLE怎么写?
...全文
60 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangwlkw 2012-08-21
  • 打赏
  • 举报
回复
把ISNULL改成NVL对了,可你写的我运行出错了,AND那有错
ORAClE SE 2012-08-21
  • 打赏
  • 举报
回复
isnull 改成nvl
SELECT Cso.f_Key,
Cso.f_Servicetype,
Cso.f_Aspnode,
Cso.f_Productline,
Cso.f_Internalclosetime,
CASE
WHEN f_Internalclosetime > Nvl(f_Complainttime, '1900-1-1') THEN
f_Internalclosetime
ELSE
Nvl(f_Complainttime, '1900-1-1')
END Maxtime
FROM Cr_Cs_Cso Cso
LEFT JOIN Cr_c_Rewardpunishrecord Rpd ON Rpd.f_Cso = Cso.f_Key
LEFT JOIN Cr_c_Rewardpunishcriteria Rpc ON Rpc.f_Key =
Rpd.f_Rewardpunishcriteria
WHERE 1 = 1
AND Rpd.f_Status = 50
AND Rpc.f_Code IN ('HTF01', 'HTF02', 'HTF03', 'HTF05', 'HTF06',
'HTF08', 'HTF09', 'HTF10', 'HTF13')
AND f_Priority IS NOT NULL
AND f_Complainttype IS NOT NULL
AND f_Complainttime IS NOT NULL
AND (f_Complainttype IN
(4003, 4006, 4007, 4008, 4005, 4009, 4019, 4034, 4030, 4029, 4018) OR
f_Priority IN (70, 60))
AND Cso.f_Status IN (160, 170, 180)
AND CASE WHEN
f_Internalclosetime > Nvl(f_Complainttime, '1900-1-1') THEN f_Internalclosetime ELSE Nvl(f_Complainttime, '1900-1-1') END AND f_Internalclosetime BETWEEN '2012-06-27 00:00:00' AND '2012-07-26 23:59:59' AND Rpd.f_Yearmonth = '2012-07'
ORAClE SE 2012-08-21
  • 打赏
  • 举报
回复
isnull 改成nvl
SELECT Cso.f_Key,
Cso.f_Servicetype,
Cso.f_Aspnode,
Cso.f_Productline,
Cso.f_Internalclosetime,
CASE
WHEN f_Internalclosetime > Nvl(f_Complainttime, '1900-1-1') THEN
f_Internalclosetime
ELSE
Nvl(f_Complainttime, '1900-1-1')
END Maxtime
FROM Cr_Cs_Cso Cso
LEFT JOIN Cr_c_Rewardpunishrecord Rpd ON Rpd.f_Cso = Cso.f_Key
LEFT JOIN Cr_c_Rewardpunishcriteria Rpc ON Rpc.f_Key =
Rpd.f_Rewardpunishcriteria
WHERE 1 = 1
AND Rpd.f_Status = 50
AND Rpc.f_Code IN ('HTF01', 'HTF02', 'HTF03', 'HTF05', 'HTF06',
'HTF08', 'HTF09', 'HTF10', 'HTF13')
AND f_Priority IS NOT NULL
AND f_Complainttype IS NOT NULL
AND f_Complainttime IS NOT NULL
AND (f_Complainttype IN
(4003, 4006, 4007, 4008, 4005, 4009, 4019, 4034, 4030, 4029, 4018) OR
f_Priority IN (70, 60))
AND Cso.f_Status IN (160, 170, 180)
AND CASE WHEN
f_Internalclosetime > Nvl(f_Complainttime, '1900-1-1') THEN f_Internalclosetime ELSE Nvl(f_Complainttime, '1900-1-1') END AND f_Internalclosetime BETWEEN '2012-06-27 00:00:00' AND '2012-07-26 23:59:59' AND Rpd.f_Yearmonth = '2012-07'
zhangwlkw 2012-08-21
  • 打赏
  • 举报
回复
and ((F_InternalCloseTime>isnull(F_ComplaintTime,to_date('1900-01-01','yyyy-mm-dd'))
错误就在大于号那
zhangwlkw 2012-08-21
  • 打赏
  • 举报
回复
00936: 确实表达式
zhangwlkw 2012-08-21
  • 打赏
  • 举报
回复
不对啊,运行后有好几个错误
人生无悔 2012-08-20
  • 打赏
  • 举报
回复

SELECT cso.F_Key, cso.F_ServiceType,cso.F_ASPNode,cso.F_Productline,cso.F_InternalCloseTime,
case WHEN F_InternalCloseTime>nvl(F_ComplaintTime,to_date('1900-01-01','yyyy-mm-dd')) THEN F_InternalCloseTime
ELSE nvl(F_ComplaintTime,to_date('1900-01-01','yyyy-mm-dd')) end MAXTime
FROM cr_cs_cso cso
left join CR_C_RewardPunishRecord rpd on rpd.f_cso = cso.f_key
left join CR_C_RewardPunishCriteria rpc on rpc.f_key = rpd.f_RewardPunishCriteria
WHERE 1=1 and rpd.f_status =50 and rpc.f_code in ('HTF01','HTF02','HTF03','HTF05','HTF06','HTF08','HTF09','HTF10','HTF13')
AND F_Priority IS NOT NULL
AND F_ComplaintType IS NOT NULL
AND F_ComplaintTime IS NOT NULL
AND (F_ComplaintType IN (4003,4006,4007,4008,4005,4009,4019,4034,4030,4029,4018) or F_Priority IN (70,60))
AND cso.F_Status in (160,170,180)
and ((F_InternalCloseTime>isnull(F_ComplaintTime,to_date('1900-01-01','yyyy-mm-dd'))
and F_InternalCloseTime BETWEEN to_date('2012-06-27','yyyy-mm-dd') AND to_date('2012-07-26 23:59:59','yyyy-mm-dd hh24:mi:ss'))
or (
isnull(F_ComplaintTime,'1900-1-1') BETWEEN to_date('2012-06-27','yyyy-mm-dd') AND to_date('2012-07-26 23:59:59','yyyy-mm-dd hh24:mi:ss')
))
and rpd.f_yearmonth='2012-07'



--你的这个语句是错的,不管在mssql还是在oracle,都不能这么用的
AND case WHEN F_InternalCloseTime>isnull(F_ComplaintTime,'1900-1-1') THEN F_InternalCloseTime
ELSE isnull(F_ComplaintTime,'1900-1-1') end BETWEEN '2012-06-27 00:00:00' AND '2012-07-26 23:59:59'

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧