Can i merge 2 query’s in N1Ql and if one key does not exist return a 0 ? I have query’s, one is a simple query which will return the content of a array in a doc which has 2 keys, key and name and looks like this …
Query
`select \`key\`,name from Contacts USE Keys 'activity_keys::1c721060-fbfd-4720-9e66-100fc8f4e73c'
Result
[ {
"key": "c28f7ead-d87b-4ad5-b6b3-1f204b013b50",
"name": "Notes Written"
},
{
"key": "d0181c74-22a9-4f99-9cc9-df3467c51805",
"name": "Pop-Bys Delivered"
},
{
"key": "90d142ea-6748-4781-b2b9-4f05aab12956",
"name": "Database Additions"
}]
The second query looks like this
`SELECT d.\`key\`, COUNT(1) AS count, d.name
FROM Contacts c
UNNEST c.Data d
WHERE c._type = "activity_dashboard_test"
AND c.userid = $1
AND d.date = DATE_FORMAT_STR($2 , '1111-11-11T00:00:00+00:00')
GROUP BY d.\`key\`, d.name`
And this Result looks like this
[{
"count": 2,
"key": "c28f7ead-d87b-4ad5-b6b3-1f204b013b50",
"name": "Notes Written"
},
{
"count": 1,
"key": "d0181c74-22a9-4f99-9cc9-df3467c51805",
"name": "Pop-Bys Delivered"
}]
So i am looking for a way to merge / join both where i want to return all from 1 query and the merge in the count value from 2nd query and if no record in 2nd return a 0 for count if posible