Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL subquery does not work #8540

Closed
mbhulin opened this issue Sep 14, 2018 · 4 comments
Closed

SQL subquery does not work #8540

mbhulin opened this issue Sep 14, 2018 · 4 comments
Assignees
Labels
Milestone

Comments

@mbhulin
Copy link

mbhulin commented Sep 14, 2018

OrientDB Version: 3.0.7 and 2.2.27

Java Version: 1.8.0_181

OS: Windows 10

Using the sample database GratefulDeadConcerts the query
SELECT AVG(performances) FROM V
results in AVG = 73

SELECT * FROM V WHERE performances < 73
returns 375 records

However the first query as a subquery
SELECT * FROM V WHERE performances < (SELECT AVG(performances) FROM V)
retrieves no records.

@luigidellaquila
Copy link
Member

Hi @mbhulin,

I think it's a problem of automatic type conversion: the subquery result is a collection and performances is a single value.
As a work-around you can do the following:

SELECT * FROM V 
LET $average = (SELECT AVG(performances) as value FROM V)
WHERE performances < $average[0].value

I'll check it ASAP and see if we can make it work also in the original case

thanks

Luigi

@luigidellaquila luigidellaquila self-assigned this Sep 14, 2018
@luigidellaquila
Copy link
Member

Hi @mbhulin

I just checked latest 3.0.x snapshot and it works fine. I fixed something similar a few days ago, so probably it's already solved

Thanks

Luigi

@mbhulin
Copy link
Author

mbhulin commented Oct 10, 2018

Hi Lugi,

unfortunately the query with subquery still does not work with OrientDB 3.0.8. Please check it.

Thanks
Martin

@luigidellaquila
Copy link
Member

Hi @mbhulin

You are right, it still fails. I'm pushing a fix right now

Thanks

Luigi

luigidellaquila added a commit that referenced this issue Oct 11, 2018
eg. WHERE foo < (SELECT avg(foo) FROM V)

Resolves: #8540
@luigidellaquila luigidellaquila added this to the 3.0.9 milestone Oct 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants