Have rich accommodation bosses don't, I have the unknown, and bosses help solve,
Select query condition in the statement, click on the query execution statement as shown in the following
- data preparation
The begin
Insert into tt_saledeptitem
Select
Shopid, shopname, managedeptid deptid, groupname,
Tradeprice tradenumber, costvalue, discvalue SaleValue, resalevalue, maoli, maolilv,
Hbtradeprice hbtradenumber, hbcostvalue hbdiscvalue, hbsalevalue, hbresalevalue, hbmaoli, hbmaolilv
The from
(select
A.s hopid, a.s hopname, arjun anagedeptid, a. d. eptid, al-qeada roupname,
A.t radeprice, a.t radenumber, a.c ostvalue, a. d. iscvalue, a.s alevalue, a.r esaleValue, arjun aoli, arjun aolilv,
C.t radeprice hbtradeprice,
A.t radenumber hbtradenumber,
Arthur c. ostvalue hbcostvalue,
C.d iscvalue hbdiscvalue,
C.s. alevalue hbsalevalue,
C.r esaleValue hbresalevalue,
C. aoli hbmaoli,
C. aolilv hbmaolilv
The from
(select
A.S hopID, b.N ame ShopName,
A. d. eptid managedeptid,
A. d. eptID, citigroup ame GroupName,
A.t radeprice, a.t radenumber,
A.S aleValue, a. d. iscValue, a.c ostvalue,
A.S aleValue - a. d. iscValue resaleValue,
A.S aleValue - a. d. iscValue - a.C ostValue maoli,
Case (a.S aleValue - a. d. iscValue) when 0 then 0 else
100.00 * (a.S aleValue - a. d. iscValue - a.C ostValue)/(a.S aleValue - a. d. iscValue) end maolilv
The from
(select
Shopid, deptid,
The sum (salevalue) salevalue,
The sum (discvalue) discvalue,
The sum (costvalue) costvalue,
The sum (tradeprice) tradeprice,
The sum (tradenumber) tradenumber
The from
(select
A.s hopid,
Trunc (a. d. eptid/(select levelvalue from deptlevel where deptlevelid=1)) deptid, - '% 1' for the variable % deptlevelid
The sum (a.s alevalue) salevalue,
The sum (a. d. iscvalue) discvalue,
The sum (a.c ostvalue) costvalue,
The sum (b.t radeprice) tradeprice,
The sum (b.t radenumber) tradenumber
The from
RPT_Saledept a, RPT_CashManageDept b
Where
To_char (a.s date, '- dd yyyy - mm) between' 2020-05-01 'and' 2020-05-31 ', query time is variable D1 D2 % % % %
And to_char (a.s date, 'yyyymmdd')=b.s date
And a.s hopid=b.s hopid
And trunc (a. d. eptid/(select levelvalue from deptlevel where deptlevelid=1))=b.S GroupID
And (a.s alevalue - a. d. iscvalue) & lt;> 0
Group by a.s hopid deptid) j
Group by
Shopid, deptid). A,
Shop, b
Sgroup c
Where
A.S hopID=b.I D
And a. d. eptID=c.I D
And a.S aleValue - a. d. iscValue<> 0
The order by
A. d. eptID). A,
Shop, b
(select
A.S hopID,
B.N ame ShopName,
A. d. eptid managedeptid,
A. d. eptID, citigroup ame GroupName,
A.t radeprice, a.t radenumber,
A.S aleValue, a. d. iscValue, a.c ostvalue,
A.S aleValue - a. d. iscValue resaleValue,
A.S aleValue - a. d. iscValue - a.C ostValue maoli,
Case (a.S aleValue - a. d. iscValue) when 0 then 0 else
100.00 * (a.S aleValue - a. d. iscValue - a.C ostValue)/(a.S aleValue - a. d. iscValue) end maolilv
The from
(select
Shopid, deptid,
The sum (salevalue) salevalue,
The sum (discvalue) discvalue,
The sum (costvalue) costvalue,
The sum (tradeprice) tradeprice,
The sum (tradenumber) tradenumber
The from
(select
A.s hopid,
Trunc (a. d. eptid/(select levelvalue from deptlevel where deptlevelid=1)) deptid,
The sum (a.s alevalue) salevalue,
The sum (a. d. iscvalue) discvalue,
The sum (a.c ostvalue) costvalue,
The sum (b.t radeprice) tradeprice,
The sum (b.t radenumber) tradenumber
The from
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull