Subtract values from SELECT in SQL I have the following 2 queries.:


shipManagementInvoiceNetValue:

SELECT IFNULL (SUM (shipManagementInvoice.netto ), 0) AS shipManagementInvoiceNetValue
FROM tckopf AS shipManagementInvoice
WHERE shipManagementInvoice.referenzid = 1
    AND shipManagementInvoice.btyp = 5

shipManagementCreditNoteNetValue:

SELECT IFNULL (SUM (shipManagementCreditNote.netto), 0) AS shipManagementCreditNoteNetValue
FROM tckopf AS shipManagementCreditNote
WHERE shipManagementCreditNote.referenzid = 1
    AND shipManagementCreditNote.btyp = 6



but I need the result shipManagementInvoiceNetValue - shipManagementCreditNoteNetValue. I'm using a HXTT JDBC DBF driver that supports more than SQL92.

How can I realize that?
try this..

SELECT X.shipManagementInvoiceNetValue - Y.shipManagementCreditNoteNetValue
FROM 
(
   SELECT IFNULL (SUM (shipManagementInvoice.netto ), 0) AS shipManagementInvoiceNetValue
   FROM tckopf AS shipManagementInvoice
   WHERE shipManagementInvoice.referenzid = 1
   AND shipManagementInvoice.btyp = 5
)X,
(
   SELECT IFNULL (SUM (shipManagementCreditNote.netto), 0) AS shipManagementCreditNoteNetValue
   FROM tckopf AS shipManagementCreditNote
   WHERE shipManagementCreditNote.referenzid = 1
   AND shipManagementCreditNote.btyp = 6
)Y