Foxpro
從 SQL 中的 SELECT 中減去值
我有以下兩個查詢:
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
但我需要結果
shipManagementInvoiceNetValue - shipManagementCreditNoteNetValue
。我使用的HXTT JDBC DBF 驅動程序支持的不僅僅是 SQL92。我怎麼能意識到這一點?
嘗試這個..
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