不确定 SQL 语法

问题描述 投票:0回答:1

我正在尝试编写一个查询,在其中提取一些数字(theowin/trips)来比较两个日期。我想查看一个表中一个月的数据添加到另一个表中的日期。我收到语法错误。 一般来说,我想知道如何修复我的 Sentax:

SELECT 
t1.PtnId, 
t2.compDate, 
(SELECT sum(t2.TheoWin)/sum(t2.Trips) 
 WHERE (t2.DateBuyIn BETWEEN t1.compDate AND DATEADD (month, 1, t1.compdate) AS '+1 Months' 
FROM t1.vVW_DWH_PTNSLots 
JOIN t2.vCXComps 
ON t1.PtnID=t2.ptnI

我的错误是:

SyntaxError: Expected "#", "%", "&", ")", "*", "+", ",", "-", "--", "/", "/*", "<<", ">>", "AND", "ON", "OR", "OVER", "^", "div", "|", "~", or [ \t\n\r] but "A" found.

我发现代码没有问题

sql sas
1个回答
0
投票

您有两个未闭合的括号:

t2.compDate, 
(SELECT 

还有

WHERE (t2.DateBuyIn
© www.soinside.com 2019 - 2024. All rights reserved.