Can you please help me know what maybe the error in my sql? I'm having missing expression error but I cannot find the error. Thank you very much in advance.
你能帮我知道我的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
Error:
ORA-00936: missing expression
00936. 00000 - "missing expression"
*Cause:
*Action:
Error at Line: 2 Column: 9
1 个解决方案
#1
2
convert(varchar(20), ...
?
转换(varchar(20),...?
As far as I know, convert
is used to convert a string from one character set to another. varchar(20)
is not a string. This is also likely to be the case since that "line 2, column 9" is exactly where the varchar(20)
is.
据我所知,convert用于将字符串从一个字符集转换为另一个字符集。 varchar(20)不是字符串。这也可能是这种情况,因为“第2行,第9列”正好是varchar(20)所在的位置。
The doco for convert
states:
转换状态的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.
convert(string1,char_set_to,[char_set_from])string1是要转换的字符串。 char_set_to是要转换为的字符集。 char_set_from是要转换的字符集。
If your intent is to cast the date difference to a varchar(20)
type, you should probably be using cast
.
如果您的目的是将日期差异转换为varchar(20)类型,则应该使用强制转换。
#1
2
convert(varchar(20), ...
?
转换(varchar(20),...?
As far as I know, convert
is used to convert a string from one character set to another. varchar(20)
is not a string. This is also likely to be the case since that "line 2, column 9" is exactly where the varchar(20)
is.
据我所知,convert用于将字符串从一个字符集转换为另一个字符集。 varchar(20)不是字符串。这也可能是这种情况,因为“第2行,第9列”正好是varchar(20)所在的位置。
The doco for convert
states:
转换状态的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.
convert(string1,char_set_to,[char_set_from])string1是要转换的字符串。 char_set_to是要转换为的字符集。 char_set_from是要转换的字符集。
If your intent is to cast the date difference to a varchar(20)
type, you should probably be using cast
.
如果您的目的是将日期差异转换为varchar(20)类型,则应该使用强制转换。