SQL错误:ORA-00936:缺少表达式

时间:2012-01-03 07:45:46

标签: sql oracle syntax

你能帮我知道我的sql中可能出现的错误吗? 我丢失了表达式错误,但我找不到错误。 非常感谢你提前。

SELECT SYSTEMNAME, round(MAX(GBL_CPU_TOTAL_UTIL),2) AS AVE_CPU,
convert(varchar(20),DATEADD(hour, DATEDIFF(hour, 0, DATETIME), 0),110) AS DATE
FROM dbo.[GLOBAL]
WHERE (SYSTEMNAME IN ( 'X1','X2','X3'))    
AND (DATETIME > DATEADD(month, - 24, GETDATE()))
AND (DATETIME BETWEEN '12-27-2011 00:00' AND '12-30-2011 00:00')
GROUP BY SYSTEMNAME, convert(varchar(20),
DATEADD(hour, DATEDIFF(hour, 0, DATETIME), 0),110)
ORDER BY DATE

错误:

ORA-00936: missing expression
00936. 00000 -  "missing expression"
*Cause:    
*Action:
Error at Line: 2 Column: 9

1 个答案:

答案 0 :(得分:2)

convert(varchar(20), ...

据我所知,convert用于将字符串从一个字符集转换为另一个字符集。 varchar(20) 不是字符串。这也可能是这种情况,因为“第2行第9列”正好是varchar(20)所在的位置。

convert州的doco:


<强> convert( string1 , char_set_to , [ char_set_from ] )
string1 is the string to be converted.
char_set_to is the character set to convert to.
char_set_from is the character set to convert from.


如果您的意图是将日期差异转换为varchar(20)类型,则应该使用cast