使用ASP查询数据库的SQL,请高手指点

zhbw 2005-11-19 01:28:06
sql="select branch_txt,sum(case when type='1' then amnt else 0 end)"
sql=sql&",sum(case when type='2' then amnt else 0 end)"
sql=sql&",sum(case when type='3' then amnt else 0 end)"
sql=sql&",sum(case when type='4' then amnt else 0 end)"
sql=sql&",sum(case when type='5' then amnt else 0 end)"
sql=sql&" from tmptj a,br001 b"
sql=sql&" where pl_date between '"&chdt(sdate)&"' and '"&chdt(edate)&"' "
sql=sql&" and a.branchno[1,4]='"&brch&"' and a.branch=b.branch_no"
执行后报“基本语法错”,但是将将上面的SQL在数据库上直接运行后成功。
是否为ASP中不存在有case when ... then ...end语法的,
请指教
...全文
121 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
xxuu503 2005-11-19
  • 打赏
  • 举报
回复
没用过那个数据库,榜你up
dh20156 2005-11-19
  • 打赏
  • 举报
回复
哦?那你这句是什么写法啊?解释一下可否?
zhbw 2005-11-19
  • 打赏
  • 举报
回复
我测试过,这个地方没有错的,
dh20156 2005-11-19
  • 打赏
  • 举报
回复
楼主没去测试一下我提示的地方么?a.branchno[1,4]='"&brch&"'这里你是否想用SUBSTRING函数而写错了呢?
zhbw 2005-11-19
  • 打赏
  • 举报
回复
a.branchno[1,4]='"&brch&"'中 brch是变量,通过APS运行后生成的完整语句如下
select branch[1,4],sum(case when ttype='1' then amnt else 0 end),sum(case when ttype='2' then amnt else 0 end),sum(case when ttype='3' then amnt else 0 end),sum(case when ttype='4' then amnt else 0 end),sum(case when ttype='5' then amnt else 0 end) from tttt where plnmio_date between '8/1/2005' and '11/19/2005' group by 1 order by 1

这个语句在INFORIX数据库上运行是成功的。但是通过ASP执行时却报错
Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e14'
[Informix][Informix ODBC Driver]General error.Syntax error
是否为INFORMIX ODBC DRIVER不支持CASE WHEN 。。。 THEN 。。。ELSE 。。。END的

moodboy1982 2005-11-19
  • 打赏
  • 举报
回复
我不赞成楼上的说法。
我认为这整个SQL是错误的。你的查询SQL语句,变成了SQL程序了。应该是错误的。
dh20156 2005-11-19
  • 打赏
  • 举报
回复
a.branchno[1,4]='"&brch&"' <-- 可能是这里手误写错了

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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