我是N1QL的新手,我试图在内部联接中查询两个不同的查询但我在下面得到了例外。 (重要的是要提到每个查询都是单独测试的 - 它运行得很好)
我的搜索结果如下:
SELECT *
FROM(
(SELECT payload.masterAdId ,
SUM(
CASE
WHEN payload.active = true
THEN 1
ELSE 0
END) AS numOfActiveversions,
SUM(
CASE
WHEN payload.active = false
THEN 1
ELSE 0
END) AS numOfDisabledVersions,
COUNT(1)AS totalVersions
FROM mvbucket
WHERE _identifier = "adsmartversion"
AND payload.accountId= 1073741826
GROUP BY payload.masterAdId limit 1
)A
JOIN
(SELECT payload.id AS masterAdId ,
payload.name AS masterAdName,
payload.adAssignmentData.campaignId,
payload.adAssignmentData.campaignName,
array_count(payload.adSmartVersionSchema.smartElements[].svKey) AS numberofdynamicelements
FROM DEFAULT
WHERE payload.massVersioning = true
AND payload.adAssignmentData.campaignId IS NOT NULL
GROUP BY payload.id,
payload.name,
payload.adAssignmentData.campaignId,
payload.adAssignmentData.campaignName,
array_count((array_star((((default.payload).adSmartVersionSchema).smartElements)).svKey))
)B
ON keys A.payload.masterAdId);
以及我获得的例外情况:
"errors": [
{
"**code": 3000,**
**"msg": "syntax error - at A"**
}
所以它似乎是连接结构的东西。是否可以在N1QL中这样做?
知道如何让它正常工作? 提前致谢
答案 0 :(得分:0)
目前,JOIN的右手术语必须是表/桶。您可以重写查询以在JOIN之后执行右手聚合。