我试图对此进行查询,但我还没有运气。表格如下:
INVOICE
ID | INVOICENUMBER | CUSTOMER | VALUE
1 | 999 | 8 | 9000
2 | 999 | 8 | 1000
INVOICE_TRANSACTION
InvoiceID | TYPE | VALUE
1 | cust | 5000
1 | cust | 2000
2 | cust | 1000
2 | cust | -1000
INVOICE_DETAIL
InvoiceID | PURCHASEORDERID
1 | 7777
PURCHASE_ORDER
PURCHASEORDERID | ORDERTYPE
7777 | gross
PURCASE_ORDER_DETAILS
PURCHASEORDERID | ROW | STATUS
7777 | 1 | 1
7777 | 2 | 2
7777 | 3 | 3
我想要的结果是这样的:
INVOICE VALUE TRANSACTION VALUE PURCHASEORDERID ORDERTYPE HIGH STATUS LOW STATUS
------- ----- ----------------- --------------- --------- ----------- ----------
1 9000 7000 7777 gross 3 1
换句话说,我希望结果对总invoice_transaction.value
大于或小于 0 的所有发票编号进行分组。我是这一切的新手,谁能帮我开始?