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.
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
convert(varchar(20), ...?As far as I know,
convertis 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 thevarchar(20)is.The doco for
convertstates: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.If your intent is to cast the date difference to a
varchar(20)type, you should probably be usingcast.