Home > database >  Oracle article ten million data table table query, how to optimize?
Oracle article ten million data table table query, how to optimize?

Time:09-16

The dialect/* */
SELECT * FROM
(
Select
CASE the WHEN '=' sales team 'THEN to_char (SALEGROUP)
WHEN '=' solicitors' THEN to_char (xsy)
WHEN '=' customer type THEN to_char (KHLB)
END AS FZTJ,
KHLB,
Xsy,
SJBM,
"The superior customer,"
FNUMBER,
"Secondary customers,"
- NVL (A2. FJSAMOUNT, 0) AS "initial amount receivable receivable sheet",
"Initial sum receivable.besides,"
"Initial paid-in amount,"
- (NVL (A2. FJSAMOUNT, 0) - NVL (A3 FActualAMOUNT, 0)) as "initial balance balance receivable sheet,"
"Initial balance balance.besides,"
"The delivery number,"
"The delivery amount,"
"This paid-in amount,"
"Credit limit",
NVL (B1. QCKPJEYS, 0) AS "the beginning did not make out an invoice receivable,"
"At the beginning did not make out an invoice outbound,"
-- "this amount receivable",
"This has make out an invoice,"
Yfje,
BQHZ,
QCHZ,
"Initial sum receivable outbound order" + "shipping amount" - "this paid-in amount" - NVL (BQHZ, 0) - NVL (QCHZ, 0) as "ending balance"
-- Y1. QMHZ,
The from (
SELECT
A1. Xsy,
A1. SALEGROUP,
A1. FParentID,
CASE the WHEN A1. SJBM IS NULL THEN A1. FNUMBER ELSE A1. The SJBM END AS SJBM,
CASE the WHEN A1. SJKH IS NULL THEN A1. FNAME_L2 ELSE A1. SJKH END AS "a superior customer,"
-- A1. SJBM,
-- A1. SJKH AS "a superior customer,"
A1. FID,
A1. FNUMBER,
A1. FNAME_L2 AS "secondary customers,"
A1. KHLB,
- NVL (A2. FJSAMOUNT, 0) AS "initial amount receivable receivable sheet",
NVL (A22. FJSAMOUNT, 0) AS "initial sum receivable.besides,"
NVL (A3. FActualAMOUNT, 0) AS "initial paid-in amount,"
- (NVL (A2. FJSAMOUNT, 0) - NVL (A3 FActualAMOUNT, 0)) as "initial balance balance receivable sheet,"
(NVL (A22. FJSAMOUNT, 0) - NVL (A3 FActualAMOUNT, 0)) as "initial balance balance.besides,"
NVL (A4. FQTY, 0) AS "shipment quantity,"
NVL (A4. HSJE, 0) AS "delivery amount,"
NVL (A9. FActualAMOUNT, 0) AS "current paid-in amount,"
NVL (A10. Xye, 0) AS "credit limit",
NVL (B1. QCKPJEYS, 0) AS "the beginning did not make out an invoice receivable,"
NVL (bb2. QCKPJECK, 0) AS "the beginning did not make out an invoice outbound,"
NVL (AA) BQYSAMOUNT, 0) AS "current accounts receivable amount,"
NVL (B2. BQKPJE, 0) AS "this issue has make out an invoice,"
Yf yfje,
Y.B QHZ, Y2 QCHZ
-- Y1. QMHZ,

- at the beginning did not make out an invoice + - this period make out an invoice receivable in current=the final did not make out an invoice
The FROM
(
- customer
Select distinct AA FID, AA FNUMBER, AA. FNAME_L2, AA. FParentID,
CASE the WHEN BB. FID IS NULL THEN AA. FID ELSE BB. FID END AS SJFID,
BB. FNUMBER AS SJBM, BB. FNAME_L2 AS SJKH, b.x sy, e.f name_l2 AS SALEGROUP,
Q.D W AS KHLB
The from T_BD_Customer AA
Left the join KHLB Q on Q.F ID=AA. The FID
- left the join T_BD_CSSPGroup Q ON Q.F ID=AA. FBrowseGroupID
LEFT the JOIN (select AA. FID, AA FNUMBER, AA. FNAME_L2
The from T_BD_Customer AA where AA. FControlUnitID='00000000-0000-0000-0000-000000000000 cce7aed4) BB ON BB. FID=AA. FParentID
Left the join (
SELECT a. *, c.f name_l2 as xsy FROM T_BD_CustomerSaleInfo a
Left the join T_BD_CustomerSaler b on a.f id=b. CustomerSaleID
Left the join T_BD_Person c on c.f id=b. PersonID
Where a.F SaleOrgID='sREAAAAAB9LM567U'
B) on b. CustomerID=AA. Fid
Left the join T_BD_SALEGROUP e on e.f id=biggest FSALEGROUPID
Where
(the biggest FSalegroupID in (") OR null IS null) and
(b. SaleOrgID='sREAAAAAB9LM567U') and
AA. FControlUnitID='00000000-0000-0000-0000-000000000000 cce7aed4'
A1)


LEFT the JOIN (
SELECT
FAcctCussentID, 0 AS SL, SUM (BQHZ) AS BQHZ
The FROM
(
- receivable rushed to deal with this issue -- -- --

Select
B. AcctCussID as FAcctCussentID,
The sum (b. ThisVerificateAmtLoc) as BQHZ
The from T_AR_VerificationBill a
Inner join T_AR_VerificationBillentry b on a.f id=b. parentid
Where
(b. CurrencyID='OR null IS null)
And b. BillSubType=2
AND to_char (a.F BizDate, '- DD YYYY - MM) & gt;
='2016-04-01'And to_char (a.F BizDate, '- DD YYYY - MM) & lt;
='2017-04-03'And a.F VerificationType in (103109)
And a.F ControlUnitID='sREAAAAAB9LM567U'
Group by b. AcctCussID
)
GROUP BY FAcctCussentID
) Y ON A1. FID=Y.F AcctCussentID

/* LEFT JOIN (
- the bad debt losses
Select a T1. FAcctCussentID, 0 AS SL,
The SUM (T1) FBadAmountsLocal) - the SUM (T1) FTakeBackAmountsLocal) AS QMHZ
The from T_AR_BadAcct T1
INNER JOIN T_ORG_Company T3 ON T1. FCompanyID=T3. The FID
Where TO_CHAR (T1) FBadAcctDate, '- DD YYYY - MM) & lt;
='2017-04-03'AND (T3) FNUMBER='sREAAAAAB9LM567U')
GROUP BY T1. FAcctCussentID
) Y1 ON A1. FID=Y1. FAcctCussentID */

LEFT the JOIN (
SELECT
FAcctCussentID, 0 AS SL, sum (QCHZ) AS QCHZ
The FROM (
- the bad debt losses
Select a T1 FAcctCussentID,
The SUM (T1) FBadAmountsLocal) - the SUM (T1) FTakeBackAmountsLocal) AS QCHZ
The from T_AR_BadAcct T1
INNER JOIN T_ORG_Company T3 ON T1. FCompanyID=T3. The FID
Where TO_CHAR (T1) FBadAcctDate, '- DD YYYY - MM) & gt;
='2016-04-01'And TO_CHAR (T1) FBadAcctDate, '- DD YYYY - MM) & lt;
='2017-04-03'AND (T3. FID='sREAAAAAB9LM567U')
GROUP BY T1. FAcctCussentID


- at the beginning of receivable rushed to deal with -- -- --
- union all
- select
- b. AcctCussID,
- the sum (b. ThisVerificateAmtLoc) as FThisVerificateAmtLoc
- the from T_AR_VerificationBill a
- inner join T_AR_VerificationBillentry b on a.f id=b. parentid
- where
- (b. CurrencyID='OR null IS null)
- and b. BillSubType=2
- AND to_char (a.F BizDate, '- DD YYYY - MM) & lt; '2016-04-01'
- and a.F VerificationType in (103109)
- and a.F ControlUnitID='sREAAAAAB9LM567U'
- group by b. AcctCussID
)
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related