Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The DISTINCT keyword eliminates duplicates in the projected query results.
In this example, the query projects values for each product category. If two categories are equivalent, only a single occurrence returns in the results.
SELECT DISTINCT VALUE
p.category
FROM
products p
[
"Accessories",
"Tools"
]
You can also project values even if the target field doesn't exist. In this case, the field doesn't exist in one of the items, so the query returns an empty object for that specific unique value.
SELECT DISTINCT
p.category
FROM
products p
The results are:
[
{},
{
"category": "Accessories"
},
{
"category": "Tools"
}
]