有如下SQL,为什么不能执行?(在线等待) (100分)

L

lbsong

Unregistered / Unconfirmed
GUEST, unregistred user!
有如下SQL,为什么不能执行?我在SQL Server的查询分析器和SQL Explorer中试过都可以执行
但是为什么在程序里用TQuery执行不了呢?

错误提示如下:
Invalid use of keyword
Token:char(8),pTo_Datetime-"8:00:00",122)
Line Number: 1.

SQL语句如下:
Select convert(char(8),pTo_Datetime-"8:00:00",112) as WorkDate,
processorID,
(select OpName from operator b where a.processorid = b.opid) as processorname,
worknode = case workflow_node
when "1" then "11"
when "2" then "22"
when "3" then "33"
when "4" then "44"
when "5" then "55"
end,
count(workflow_node) as SHULIANG from job_log a
where process_status = "2"
and convert(char(8),pTo_Datetime-"8:00:00",112) >= "20021006"
and convert(char(8),pTo_Datetime-"8:00:00",112) <= "20021016"
group by convert(char(8),pTo_Datetime-"8:00:00",112),
processorID,workflow_node order by workdate desc,processorID
在线等待,谢谢大侠
 
Select convert(char(8),pTo_Datetime-"8:00:00",112) as WorkDate,
processorID,
(select OpName from operator b where a.processorid = b.opid) as processorname,
(case workflow_node
when "1" then "11"
when "2" then "22"
when "3" then "33"
when "4" then "44"
when "5" then "55"
end) as worknode ,
count(workflow_node) as SHULIANG from job_log a
where process_status = "2"
and convert(char(8),pTo_Datetime-"8:00:00",112) >= "20021006"
and convert(char(8),pTo_Datetime-"8:00:00",112) <= "20021016"
group by convert(char(8),pTo_Datetime-"8:00:00",112),
processorID,workflow_node order by workdate desc,processorID
 
字符串和日期格式可以直接赋值
chrDateTime char(8),
DtmDateTime Datetime
--....................
chrDateTime=DtmDateTime
--.......................................
DtmDateTime= chrDateTime
 
to pengjinlongex:
不行,错误提示一样
to yanghai0437:
你大概理解错我的意思了吧
 
sorry,忘了一件非常重要的事:指定Database
其他都没有问题,谢谢各位
 
顶部