SELECT SUM returns a row when there are no records

Posted by Jose L Martinez-Avial on Stack Overflow See other posts from Stack Overflow or by Jose L Martinez-Avial
Published on 2010-03-13T02:07:48Z Indexed on 2010/03/13 2:17 UTC
Read the original article Hit count: 389

Filed under:
|

Hi,

I'm finding some problems with a query that returns the sum of a field from a table for all the records that meet certain conditions. I expected to receive a "No records found' when there were no records, but instead I'm receiving a null result.

SQL> SELECT * FROM DUAL WHERE 1=2;

no rows selected
SQL> SELECT SUM(dummy) FROM DUAL WHERE 1=2;

SUM(DUMMY)
----------


SQL>

Is there any way to not receive any record in that case?

© Stack Overflow or respective owner

Related posts about sql

Related posts about sum