使用Golang代码中的SQL查询获取语法ERRO。对于Golang的此SQL查询,需要适当的语法:
rows, errQuery := dbCon.Query("SELECT B.LatestDate
,A.SVRName AS ServerName
,A.DRIVE
,A.TotalSpace_GB AS TotalSpaceGB
,(ISNULL(A.TotalSpace_GB, 0) - ISNULL(A.FreeSpace_GB, 0)) AS
UsedSpaceGB
,A.FreeSpace_GB AS FreeSpaceGB
,CASE
WHEN ((A.FreeSpace_GB / A.TotalSpace_GB) * 100) between 25 and
35
THEN 1
WHEN ((A.FreeSpace_GB / A.TotalSpace_GB) * 100) <= 25 THEN 2
ELSE 0
END AS WARNINGSTATUS
FROM Table_ServerDiskSpaceDetails A WITH (NOLOCK)
INNER JOIN (
SELECT SVRName
,MAX(Dt) LatestDate
FROM Table_ServerDiskSpaceDetails WITH (NOLOCK)
GROUP BY SVRName
) B ON A.Dt = B.LatestDate
AND A.SVRName = B.SVRName
ORDER BY WARNINGSTATUS DESC
,ServerName
,A.Drive")