where count clause doesn't return anything

25 views
Skip to first unread message

dboden...@problemsolutions.net

unread,
Sep 29, 2017, 3:09:13 PM9/29/17
to OrientDB
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?

Luigi Dell'Aquila

unread,
Oct 2, 2017, 3:47:03 AM10/2/17
to orient-...@googlegroups.com
Hi,

This is the same in old style RDBMS, you would have to use a HAVING it this case, but OrientDB doesn't support HAVING, so you have to use a subquery (that is what you are correctly doing)

Thanks

Luigi


--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

dboden...@problemsolutions.net

unread,
Oct 2, 2017, 8:13:24 AM10/2/17
to OrientDB
Thanks for the response. I wasn't aware of the having clause before today. I appreciate your help.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages