执行ORACLE SQL语句,报ora-00907 缺少右括号

litterant 2010-10-16 10:25:40
select slm,substr(id,1,1) lb,sum(zajs) ajsnum,sum(wz) wznum,sum(tzz) tzznum,sum(dt) dtnum from ywk_xmxx join xtwh_struct_class on dh like 'substr(id,1,1)%' where length(slh)=2 and
jgrq>=To_date(2010-7-1 00:00:00,'yyyy-mm-dd hh:mm:ss') and
jgrq<=To_date(2010-10-16 23:59:59,'yyyy-mm-dd hh:mm:ss') group by slm,substr(id,1,1)

请各位大侠帮忙分析下,谢谢
...全文
389 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
hongqi162 2010-10-18
  • 打赏
  • 举报
回复
oracle to_date应该这样用
to_date('2010-7-1 00:00:00','yyyy-mm-dd hh24:mi:ss')



from ywk_xmxx join xtwh_struct_class on dh like 'substr(id,1,1)%' //问题在这里,这里是什么意思?
y_zp2010 2010-10-18
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 ecjtu5208 的回复:]

SQL code

select slm,substr(id,1,1) lb,sum(zajs) ajsnum,sum(wz) wznum,sum(tzz) tzznum,sum(dt) dtnum from ywk_xmxx join xtwh_struct_class on dh like 'substr(id,1,1)%' where length(slh)=……
[/Quote]
应该是这样的,加上引号
ecjtu5208 2010-10-18
  • 打赏
  • 举报
回复
不好意思,贴了一下,没改

select slm,substr(id,1,1) lb,sum(zajs) ajsnum,sum(wz) wznum,sum(tzz) tzznum,sum(dt) dtnum from ywk_xmxx join xtwh_struct_class on dh like 'substr(id,1,1)%' where length(slh)=2 and
jgrq>=To_date('2010-7-1 00:00:00','yyyy-mm-dd hh:mm:ss') and
jgrq<=To_date('2010-10-16 23:59:59','yyyy-mm-dd hh:mm:ss') group by slm,substr(id,1,1)

ecjtu5208 2010-10-18
  • 打赏
  • 举报
回复
看了一下,于是改成

select slm,substr(id,1,1) lb,sum(zajs) ajsnum,sum(wz) wznum,sum(tzz) tzznum,sum(dt) dtnum from ywk_xmxx join xtwh_struct_class on dh like 'substr(id,1,1)%' where length(slh)=2 and
jgrq>=To_date(2010-7-1 00:00:00,'yyyy-mm-dd hh:mm:ss') and
jgrq<=To_date(2010-10-16 23:59:59,'yyyy-mm-dd hh:mm:ss') group by slm,substr(id,1,1)
ecjtu5208 2010-10-18
  • 打赏
  • 举报
回复

select slm,substr(id,1,1) lb,sum(zajs) ajsnum,sum(wz) wznum,sum(tzz) tzznum,sum(dt) dtnum from ywk_xmxx join xtwh_struct_class on dh like 'substr(id,1,1)%' where length(slh)=2 and
jgrq>=To_date(2010-7-1 00:00:00,'yyyy-mm-dd hh:mm:ss') and
jgrq<=To_date(2010-10-16 23:59:59,'yyyy-mm-dd hh:mm:ss') group by slm,substr(id,1,1)

kye_jufei 2010-10-18
  • 打赏
  • 举报
回复
把To_date常量加單引號。。。
litterant 2010-10-18
  • 打赏
  • 举报
回复
from ywk_xmxx join xtwh_struct_class on dh like 'substr(id,1,1)%' 这语句确实有问题,老是取不到正确值

最终语句为:

select slm,substr(dh,1,3) lb,sum(zajs) ajsnum,sum(wz) wznum,sum(tzz) tzznum,sum(dt) dtnum from ywk_xmxx,xtwh_struct_class where length(slh)=4 and substr(dh,1,3)=substr(id,1,3) and jgrq>=To_date('2001-10-18 00:00:00','yyyy-mm-dd hh24:mi:ss') and jgrq<=To_date('2010-10-18 23:59:59','yyyy-mm-dd hh24:mi:ss') group by slm,substr(dh,1,3)

谢谢各位,结贴

老之 2010-10-17
  • 打赏
  • 举报
回复
两个日期常量用单引号括起来试试

2,497

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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