need to left join in N1QL,Couchbase

334 views Asked by At

I have below 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,
}

I am trying below query

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'

it is bring below result

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

BUT

I need output like below

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

I need to here RIGHT JOIN like MySQL.

Can I do it here in N1QL ??

if Yes then how can I do it ??

0

There are 0 answers