我的数据库中有以下表格。
方:
Column Name Data Type Nullable Default Primary Key
PARTY_ID NUMBER No - 1
PARTY_DESC VARCHAR2(200) No - -
PARTY_CREDIT_LIMIT NUMBER No - -
PARTY_STATUS NUMBER No - -
PARTY_ADDRESS VARCHAR2(200) No - -
PARTY_OFFICE VARCHAR2(12) Yes - -
PARTY_CELLPHONE VARCHAR2(12) Yes - -
PARTY_RESIDENCE VARCHAR2(12) Yes - -
PARTY_DUE_DATE_LIMIT NUMBER No - -
PARTY_CURRENT_BALANCE NUMBER Yes 0 -
PARTY_PROFIT_GAINED NUMBER Yes 0 -
PARTY_TURNOVER NUMBER Yes 0 -
CITY_ID NUMBER No - -
PARTY_OPENING_BAL NUMBER Yes - -
采购:
PURCHASE_ID NUMBER No - 1
PARTY_ID NUMBER No - -
U_NAME VARCHAR2(50) No - -
PURCHASE_DISCOUNT_RS NUMBER Yes 0 -
PURCHASE_DISCOUNT_P NUMBER Yes 0 -
PURCHASE_FREIGHT NUMBER Yes 0 -
PURCHASE_LUMPSUM_DISCOUNT NUMBER Yes 0 -
PURCHASE_GROSS_VALUE NUMBER No - -
PURCHASE_NET_INVOICE_VALUE NUMBER No - -
PURCHASE_DATE TIMESTAMP(6) Yes systimestamp -
出售:
SALE_ID NUMBER No - 1
PARTY_ID NUMBER No - -
U_NAME VARCHAR2(50) No - -
SALE_DISCOUNT_RS NUMBER Yes 0 -
SALE_DISCOUNT_P NUMBER Yes 0 -
SALE_FREIGHT NUMBER Yes 0 -
SALE_CARTONS NUMBER Yes 0 -
SALE_CARTON_RATE NUMBER Yes 0 -
SALE_BOX NUMBER Yes 0 -
SALE_BOX_RATE NUMBER Yes 0 -
SALE_LUMPSUM_DISCOUNT NUMBER Yes 0 -
SALE_GROSS_VALUE NUMBER Yes - -
SALE_GROSS_INVOICE_VALUE NUMBER Yes - -
SALE_NET_INVOICE_VALUE NUMBER Yes - -
SALE_DATE TIMESTAMP(6) Yes systimestamp -
我想要一个查询导致这样的事情:
date , desc , Tr No. , Debit , Credit , Balance
01/06/2010 , opening balance , , , , 720
02/06/2010 , Sale , 23 , 170 , , 890
03/06/2010 , Purchase , 54 , , 100 , 790
30/06/2010 , closing balance , , , , 790
我不知道如何进行上一栏中的计算。以及如何在一列中获得购买和销售列。