它只是告诉我附近有一个错误。。有什么帮助吗?这是否意味着问题是在一个空间附近?我看到其他人在'<'附近的错误有类似的问题要么 ';'但不只是“。
SELECT CO.JCCo, CO.Contract, CO.PCO AS PCO, CO.PCOType, MAX(CO.COStatus) AS Status, MAX(CO.COApprovedYN) AS Approved,
SUM(CO.COContPendAmt) AS PriceAmount,
SUM(CO.COCostDollars) AS CostAmount,
SUM(CO.COContPendAmt) - SUM(CO.COCostDollars) AS CO_Profit,
PMOP.Description, PMOP.PendingStatus, MAX(PMOP.DateCreated) AS PODate, GETDATE() AS Today, DATEDIFF(d, MAX(PMOP.DateCreated), GETDATE()) AS DaysOutstanding, (CASE WHEN (DATEDIFF(d, MAX(PMOP.DateCreated), GETDATE())) < 30 THEN 'Less than 30'
WHEN (DATEDIFF(d, MAX(PMOP.DateCreated), GETDATE())) > 30 AND (DATEDIFF(d, MAX(PMOP.DateCreated), GETDATE())) <= 60 THEN ' 30 - 60 ' WHEN (DATEDIFF(d, MAX(PMOP.DateCreated), GETDATE())) > 60 AND (DATEDIFF(d, MAX(PMOP.DateCreated), GETDATE())) <= 90 THEN ' 60 - 90 '
WHEN (DATEDIFF(d, MAX(PMOP.DateCreated), GETDATE())) > 90 THEN ' Over 90 ' ELSE 'Less than 30' END) AS AgingCategory,
PMOI.FixedAmount AS FixedAmount, PMOI.PendingAmount AS PendingAmount, PMOI.PCOItem,
(SELECT JCJM.ProjectMgr FROM JCJM WHERE JCJM.Job = CO.Contract AND JCJM.JCCo = 1) AS ProjectManager
FROM brvJCCostRevChgOrders AS CO
RIGHT JOIN PMOP ON CO.PCOType = PMOP.PCOType AND CO.PCO = PMOP.PCO AND CO.Contract = PMOP.Contract
RIGHT JOIN PMOI ON PMOP.PCOType = PMOI.PCOType AND PMOP.PCO = PMOI.PCO AND PMOP.Project = PMOI.Project
WHERE (PMOP.PendingStatus = 0) AND (CO.JCCo = 1) AND PMOP.Status <> 'VOID' AND PMOI.PMCo = 1 AND PMOP.PMCo = 1 AND (SELECT JCJM.ProjectMgr FROM JCJM WHERE JCJM.Job = CO.Contract AND JCJM.JCCo = 1) IS NOT NULL
GROUP BY CO.JCCo, CO.Contract, CO.PCO, PMOP.Description, CO.PCOType, PMOP.PendingStatus, PMOI.PCOItem, PMOI.FixedAmount, PMOI.PendingAmount
ORDER BY CO.Contract, CO.PCOType
答案 0 :(得分:0)
这部分......
WHEN (DATEDIFF(d, MAX(PMOP.DateCreated), GETDATE())) > 30 AND (DATEDIFF(d, MAX(PMOP.DateCreated), GETDATE())) <= 60 THEN ' 30 - 60 ' WHEN (DATEDIFF(d, MAX(PMOP.DateCreated), GETDATE())) > 60 AND (DATEDIFF(d, MAX(PMOP.DateCreated), GETDATE())) <= 90 THEN ' 60 - 90 '
WHEN (DATEDIFF(d, MAX(PMOP.DateCreated), GETDATE())) > 90 THEN ' Over 90 ' ELSE 'Less than 30' END) AS AgingCategory,
在开头缺少CASE
,最后似乎有一个胭脂括号。
以下是更正后的版本:
CASE
WHEN (DATEDIFF(d, MAX(PMOP.DateCreated), GETDATE())) > 30 AND (DATEDIFF(d, MAX(PMOP.DateCreated), GETDATE())) <= 60
THEN ' 30 - 60 ',
WHEN (DATEDIFF(d, MAX(PMOP.DateCreated), GETDATE())) > 60 AND (DATEDIFF(d, MAX(PMOP.DateCreated), GETDATE())) <= 90
THEN ' 60 - 90 ',
WHEN (DATEDIFF(d, MAX(PMOP.DateCreated), GETDATE())) > 90
THEN ' Over 90 '
ELSE 'Less than 30'
END AS AgingCategory,
答案 1 :(得分:0)
要获取完整的错误消息,请将SQL代码复制到SQL Server Management Studio中。选择所需的数据库并运行它。如果任何字符出现问题,它将在“消息”选项卡中显示如下。
如果仍然很难说,你可以双击错误,它会带你到错误的代码行。