Sample Header Ad - 728x90

How to IFNULL or COALESCE rewrite in a SQL query?

0 votes
3 answers
2203 views
I there a way to rewrite a SQL query, so I can avoid IFNULL or COALESCE, because the HXTT DBF JDBC driver (supports SQL92) throws the following error.: Caused by: java.sql.SQLException: The aggregate function SUM(NETTO) can only be used in select-list, HAVING clause, and ORDER BY clause of SELECT statement. The following query causes the above error.: SELECT ( SELECT IFNULL (SUM (shipManagementInvoice.netto ), 0) AS shipManagementInvoiceNetValue FROM tckopf AS shipManagementInvoice WHERE shipManagementInvoice.referenzid = 1 AND shipManagementInvoice.btyp = 5 ) - ( SELECT IFNULL (SUM (shipManagementCreditNote.netto), 0) AS shipManagementCreditNoteNetValue FROM tckopf AS shipManagementCreditNote WHERE shipManagementCreditNote.referenzid = 1 AND shipManagementCreditNote.btyp = 6 ) AS shipManagementResult If I remove IFNULL or COALESCE, there is no error.
Asked by BuZZ-dEE (131 rep)
Feb 13, 2014, 08:34 AM
Last activity: Feb 13, 2014, 01:04 PM