The thing is that it does return one row.
Here's the thing.
SELECT...
FROM...
WHERE...
GROUP BY...
HAVING randomNumber > (SELECT value FROM.....)
Whenever I have signs such as =, > it always returns me this error. When I do IN it doesn't.
Are you not supposed to use comparison signs when comparing to another table?
When the subquery returns one or more rows of values, the subquery is only evaluated once and then the row(s) of values is returned to outer query to use.
Answer: This error message appears when you try to use subquery (correlated or not) that returns more than one value to the calling query. This usually indicates that there are duplicate entries in the column of a table where it's expected to be unique.
This is not permitted when the subquery follows =, != , <, <= , >, >= or when the subquery is used as an expression. 'Document' (RDOC)
A scalar subquery is a subquery that returns a single value. This is the simplest form of a subquery, and can be used in most places a literal or single column value is valid.
When you type:
SomeValue IN (SELECT ...)
it is equivalent to using:
SomeValue = ANY (SELECT ...)
Don't use the second notation - but it illustrates a point. When the SELECT returns more than one value, you must use ANY or ALL with the comparator. When you omit ANY or ALL, then you must have a SELECT that returns exactly one value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With