需要离开加入N1QL,Couchbase

时间:2016-12-20 13:19:36

标签: couchbase n1ql

我在json以下

1)

"Cronresult|12":{

      "_type": "DailyCampaignUsage",
      "bids": [
        {
          "clicks": 3,
        }
      ],
      "campaignId": 2614,
}

2).A

"campaign|2614"{
"country": 14,
 "_id": 2614,
}

2).B

"campaign|31"{
"country": 12,
 "_id": 31,
}

我正在尝试下面的查询

SELECT Campaign.country,count(DISTINCT Campaign._id) campaigns,
SUM(ARRAY_SUM(DailyCampaignUsage.`statistics`[*].clicks)) clicks,
FROM Inheritx DailyCampaignUsage  
JOIN Inheritx Campaign ON KEYS ('Campaign|'||TOSTRING(DailyCampaignUsage.campaignId))       
where  DailyCampaignUsage._type='DailyCampaignUsage'

带来结果

{
    "country": "14",
    "campaigns": 2614,
    "clicks":3 
    }

BUT

我需要输出如下

    {
   "country": "12",
   "campaigns": 31,
   "clicks":0
    },
    {
    "country": "14",
    "campaigns": 2614,
    "clicks":3 
    },

我需要像MySQL一样 RIGHT JOIN

我可以在 N1QL ??

中执行此操作

如果是,那我该怎么办?

0 个答案:

没有答案