Group by Query - Need to return results only if size of each group is > 1

Hi

We have a query where we need to group by 3 attributes of the document and later display the results only if the each group size is more than 1. Please let me know if this can be achieved by N1QL ??

SELECT **********
WHERE _class=“XXXXX”
GROUP BY AAA,BBB,CCC

Regards,
Venkat

Use the HAVING clause. e.g.

select airline, destinationairport, equipment, count(1)
 from `travel-sample` 
where type = 'route'
group by airline, destinationairport, equipment 
having count(1) > 100;

(You can omit the COUNT from the select-list.)

HTH.

3 Likes

Thanks that did work