I am using orientdb version 2.2.0 and I have noticed that if I try to select a COUNT and do a where count > 5 on it, that the query returns nothing. For this to work I need to make it a subquery and then it works there. My data below is assuming that I have a vertex called User and Term with an edge called searched between them which contains some data such as employeeId and q which is just the term's value.
The following is what I have to do to get it to work properly:
select from (select employeeId, count(employeeId) from searched WHERE q.toLowerCase() LIKE '%metal%' group by employeeId ORDER BY count DESC) WHERE count >= 5
I would like to know why this doesn't work with the count part of the where. I also tried renaming the count to other values, but it doesn't matter what it is called:
select employeeId, count(employeeId) from searched WHERE q.toLowerCase() LIKE '%metal%' and count > 4 group by employeeId ORDER BY count DESC
I just don't understand why I have to use a subquery to get it to work properly. Can anybody please provide some insight on this issue?