N1QL subquery in select

@prasad Thanks for the reply. I am using Version: 4.5.0-2601 Community Edition (build-2601)

As per your suggestion i tried with the below query

SELECT
DISTINCT s.Platform,
COUNT(DISTINCT s.Channel) AS Channels,
COUNT(DISTINCT s.Advertisement) AS Advertisements,
SUM(CASE WHEN s.Click == “1” THEN 1 ELSE 0 END) AS TotalClicks,
SUM(CASE WHEN s.Impression == “1” THEN 1 ELSE 0 END) AS TotalImpressions,
ARRAY_AGG((SELECT COUNT(DISTINCT IpAddress) AS UniqueClicks FROM default USE KEYS s.Platform WHERE Click = “1” group by Platform)) AS UniqueClicks
FROM
default AS s
GROUP BY
s.Platform
ORDER BY
Platform

But still its not working. It gives me the following output. In the above query Platform is not the PrimaryKey or Document Key.

[
{
“Advertisements”: 2,
“Channels”: 1,
“Platform”: “Desktop”,
“TotalClicks”: 6,
“TotalImpressions”: 6,
“UniqueClicks”: [
[
{
“UniqueClicks”: 0
}
],
[
{
“UniqueClicks”: 0
}
],
[
{
“UniqueClicks”: 0
}
],
[
{
“UniqueClicks”: 0
}
],
[
{
“UniqueClicks”: 0
}
],
[
{
“UniqueClicks”: 0
}
]
]
},
{
“Advertisements”: 1,
“Channels”: 1,
“Platform”: “Mobile”,
“TotalClicks”: 3,
“TotalImpressions”: 3,
“UniqueClicks”: [
[
{
“UniqueClicks”: 0
}
],
[
{
“UniqueClicks”: 0
}
],
[
{
“UniqueClicks”: 0
}
]
]
}
]

So is it possible to make joins or sub-query with any other key then primary key.

Your help would be appreciated.

Regards,
Siddharth Ruchwani