[Gambas-user] SQL Bug?

Stephen Bungay sbungay at ...981...
Tue Aug 22 21:07:30 CEST 2006


  Here is some output from mysql running the two selects...

mysql> SELECT COALESCE(SUM(rec_payment),rec_payment,0) AS Payment FROM 
tbl_salespayments  WHERE rec_create > 1158921569;
+---------+
| Payment |
+---------+
|       0 |
+---------+
1 row in set (0.00 sec)

mysql> SELECT COALESCE(SUM(rec_payment),rec_payment,0) AS Payment FROM 
tbl_salespayments  WHERE rec_create < 1158921569;
+---------+
| Payment |
+---------+
| 10276.5 |
+---------+
1 row in set (0.00 sec)


  Here we're using COALESCE to ensure that a 0 is returned if nothing at all 
is summed, and it works as expected. However if either of these two SELECTS 
are executed within the database manager the result 10276.5 is returned.




More information about the User mailing list