标签:lte const dba rnn mount next arch ber money
--- 建立表空间文件(物理地址)----------
create tablespace buiqudb
logging
datafile ‘E:\DB\ORADBDATA\buiqudb.dbf‘
size 10240m
autoextend on
next 500m maxsize 20480m
extent management local;
---- 建立用户名 ------------------------- identified by 是密码
drop user TWACT cascade;
create user TWACT identified by TWACT2016 default tablespace buiqudb;
grant connect,resource,dba to TWACT; --- 授权
---- 改密码 ---------------------------
alter user system identified by THEWAYUSER account unlock;
----- 通过DBLINKS 桥接 拷贝 --------------
CREATE TABLE bma_productimages AS SELECT * FROM bma_productimages@MGTVDB;
----- 建表 ------------------
ALTER TABLE BTBTEST.PROVIDEEDU
DROP PRIMARY KEY CASCADE;
DROP TABLE BTBTEST.PROVIDEEDU CASCADE CONSTRAINTS;
CREATE TABLE BTBTEST.PROVIDEEDU
(
PROVIDEEDU_ID INTEGER NOT NULL,
PEOID INTEGER,
ACCOUNTMONEY NUMBER(14,2) DEFAULT 0,
PEOREMAINEDU NUMBER(14,2),
LOCKMONEY NUMBER(14,2) DEFAULT 0,
BMONEY NUMBER(14,2),
ISVALID INTEGER DEFAULT 1 NOT NULL,
CREDATE DATE,
UPDATEDATE DATE,
TREMARK VARCHAR2(60 BYTE),
OUTLOCKMONEY NUMBER(14,2) DEFAULT 0,
EFFMONEY NUMBER(14,2) DEFAULT 0,
CREDMAINMONEY NUMBER(14,2) DEFAULT 0
)
COMMENT ON TABLE BTBTEST.PROVIDEEDU IS ‘企业资金‘;
COMMENT ON COLUMN BTBTEST.PROVIDEEDU.PROVIDEEDU_ID IS ‘企业资金表id‘;
COMMENT ON COLUMN BTBTEST.PROVIDEEDU.PEOID IS ‘供应商企业id‘;
COMMENT ON COLUMN BTBTEST.PROVIDEEDU.PEOREMAINEDU IS ‘剩余额度‘;
COMMENT ON COLUMN BTBTEST.PROVIDEEDU.LOCKMONEY IS ‘锁定额度‘;
COMMENT ON COLUMN BTBTEST.PROVIDEEDU.BMONEY IS ‘保证金‘;
COMMENT ON COLUMN BTBTEST.PROVIDEEDU.ISVALID IS ‘是否有效 0:无效 1:有效‘;
COMMENT ON COLUMN BTBTEST.PROVIDEEDU.CREDATE IS ‘创建日期‘;
COMMENT ON COLUMN BTBTEST.PROVIDEEDU.UPDATEDATE IS ‘余额最后修改时间‘;
COMMENT ON COLUMN BTBTEST.PROVIDEEDU.OUTLOCKMONEY IS ‘出金锁定金额‘;
COMMENT ON COLUMN BTBTEST.PROVIDEEDU.EFFMONEY IS ‘可用余额(可出金和可购买的余额),总余额-锁定资
金‘;
COMMENT ON COLUMN BTBTEST.PROVIDEEDU.CREDMAINMONEY IS ‘暂未启用‘;
----------- 创建存储过程 ----------------------
CREATE OR REPLACE PACKAGE BTBTEST.PACK_FX AS
TYPE Result IS REF CURSOR;
-- 我自已作为经销销,供应商(父)给我的销售等级为
procedure Getmycredclass(
fatherpeoid_in in integer, -- 父亲企业id (供应商企业id)
sonpeoid_in in integer, -- 儿子企业id (客户企业id)
myResult out Result);
END PACK_FX;
CREATE OR REPLACE PACKAGE BODY BTBTEST.PACK_FX AS
-- 我自已作为经销销,供应商(父)给我的销售等级为
procedure Getmycredclass(
fatherpeoid_in in integer, -- 父亲企业id (供应商企业id)
sonpeoid_in in integer, -- 儿子企业id (客户企业id)
myResult out Result)
as
begin
open myResult for
select peocreditclass ,
decode(peocreditclass,1,‘一级‘,2,‘二级‘,3,‘三级‘,4,‘四级‘,‘
普通‘) as creditclassname
from creditclasshis
where fatherpeoid = fatherpeoid_in and
peoid = sonpeoid_in and
ISVALID = 1 ;
end Getmycredclass;
END PACK_FX;
DROP view V_UNMATERIAL_Order
create view V_UNMATERIAL_Order as
select a.*,
(select MATERIALNAME from UNMATERIAL where KEYID=a.MATERIAL_ID) as MATERIALNAME,
--名称
(select MATERIALNAME2 from UNMATERIAL where KEYID=a.MATERIAL_ID) as MATERIALNAME2,
--别名
(select GOODSPEC from UNMATERIAL where KEYID=a.MATERIAL_ID) as GOODSPEC, --规格
(select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID) as APRICE, --单价
(select SAFETYONE from UNMATERIAL where KEYID=a.MATERIAL_ID) as SAFETYONE, --编码
(select SINFO from UNMATERIAL where KEYID=a.MATERIAL_ID) as SINFO, --说明
(select UNITNAME from SYS_UNIT b ,UNMATERIAL c where b.KEYID=c.GOODSUNIT and
c.KEYID=a.MATERIAL_ID) as UNITNAME , --计量单位
((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID) * a.INNUM) as INAPRICE,
((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID) * a.OUTNUM) as OUTPRICE
from UNMATERIAL_Order a
select to_char(exportDate,‘yyyy-mm‘),sum(amount) from table1 group by to_char
(exportDate,‘yyyy-mm‘)
select --a.*,
--(select MATERIALNAME from UNMATERIAL where KEYID=a.MATERIAL_ID) as MATERIALNAME,
--名称
--(select MATERIALNAME2 from UNMATERIAL where KEYID=a.MATERIAL_ID) as
MATERIALNAME2, --别名
--(select GOODSPEC from UNMATERIAL where KEYID=a.MATERIAL_ID) as GOODSPEC, --规格
--(select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID) as APRICE, --单价
--(select SAFETYONE from UNMATERIAL where KEYID=a.MATERIAL_ID) as SAFETYONE, --编
码
--(select SINFO from UNMATERIAL where KEYID=a.MATERIAL_ID) as SINFO, --说明
--(select UNITNAME from SYS_UNIT b ,UNMATERIAL c where b.KEYID=c.GOODSUNIT and
c.KEYID=a.MATERIAL_ID) as UNITNAME , --计量单位
--((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID) * a.INNUM) as
INAPRICE, --入库金额
--((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID) * a.OUTNUM) as
OUTPRICE, --出库金额
select
to_char(a.CREDATE,‘yyyy-mm‘),
sum(a.INNUM),
sum(a.OUTNUM),
sum(((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID) * a.INNUM)),
sum(((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID) * a.OUTNUM))
from UNMATERIAL_Order a
group by to_char(a.CREDATE,‘yyyy-mm‘)
drop view V_GV_UNMATERIAL_Order
create view V_GV_UNMATERIAL_Order as
select
b.MATERIALname,
b.GOODSPEC,
b.SAFETYONE,
a.OUTOFSTORAGETYPE,
a.UNMATERIAL_ID,
sum(a.INNUM) as innum,
sum(a.OUTNUM) as outnum,
sum(((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID) * a.INNUM)) as
inprice,
sum(((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID) * a.OUTNUM)) as
outprice,
to_char(a.CREDATE,‘yyyy-mm‘) as datetime
from UNMATERIAL_Order a ,UNMATERIAL b where a.MATERIAL_id = b.MATERIAL_id
group by to_char(a.CREDATE,‘yyyy-
mm‘),b.MATERIALname,b.GOODSPEC,b.SAFETYONE,a.OUTOFSTORAGETYPE,a.UNMATERIAL_ID
select name,sum(yuwen) yuwen,sum(shuxue) shuxue from
(
select name,chengji yuwen,‘0‘ shuxue from fzq
where kecheng=‘yuwen‘ union
select name,‘0‘ yuwen,chengji shuxue
from fzq
where kecheng=‘shuxue‘
) aaa
group BY name;
select name,
sum(case kecheng when ‘yuwen‘ then chengji end) yuwen,
sum(case kecheng when ‘shuxue‘ then chengji end) shuxue
from fzq
group by name;
select
to_char(a.CREDATE,‘yyyy-mm‘),
b.MATERIALname,
sum(a.INNUM),
sum(a.OUTNUM),
sum(((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID) * a.INNUM)),
sum(((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID) * a.OUTNUM))
from UNMATERIAL_Order a ,UNMATERIAL b where a.MATERIAL_id = b.MATERIAL_id
group by to_char(a.CREDATE,‘yyyy-mm‘),b.MATERIALname
Select student_no,
max(decode(field_name,‘student_name‘,field_value)) As student_name,
max(decode(field_name,‘student_sex‘,field_value )) As student_sex
From cuc_student_y Group By student_no;
SELECT YEAR(日期字段) 年度,SUM(CASE WHEN MONTH(日期字段) =1 THEN 统计的字段 ELSE 0 END) 一月,
SUM(CASE WHEN MONTH(日期字段) =2 THEN 统计的字段 ELSE 0 END) 二月,
SUM(CASE WHEN MONTH(日期字段) =3 THEN 统计的字段 ELSE 0 END) 三月,
SUM(CASE WHEN MONTH(日期字段) =4 THEN 统计的字段 ELSE 0 END) 四月,
SUM(CASE WHEN MONTH(日期字段) =5 THEN 统计的字段 ELSE 0 END) 五月,
SUM(CASE WHEN MONTH(日期字段) =6 THEN 统计的字段 ELSE 0 END) 六月,
SUM(CASE WHEN MONTH(日期字段) =7 THEN 统计的字段 ELSE 0 END) 七月,
SUM(CASE WHEN MONTH(日期字段) =8 THEN 统计的字段 ELSE 0 END) 八月,
SUM(CASE WHEN MONTH(日期字段) =9 THEN 统计的字段 ELSE 0 END) 九月,
SUM(CASE WHEN MONTH(日期字段) =10 THEN 统计的字段 ELSE 0 END) 十月,
SUM(CASE WHEN MONTH(日期字段) =11 THEN 统计的字段 ELSE 0 END) 十一月,
SUM(CASE WHEN MONTH(日期字段) =12 THEN 统计的字段 ELSE 0 END) 十二月,
FROM 表
GROUP BY YEAR(日期字段)
select
b.MATERIALname, --商品名称
b.GOODSPEC, -- 规格
b.SAFETYONE, --编码
sum(decode(to_char(a.CREDATE,‘mm‘),‘01‘,a.INNUM,0)) innum1,
sum(decode(to_char(a.CREDATE,‘mm‘),‘02‘,a.INNUM,0)) innum2,
sum(decode(to_char(a.CREDATE,‘mm‘),‘03‘,a.INNUM,0)) innum3,
sum(decode(to_char(a.CREDATE,‘mm‘),‘04‘,a.INNUM,0)) innum4,
sum(decode(to_char(a.CREDATE,‘mm‘),‘05‘,a.INNUM,0)) innum5,
sum(decode(to_char(a.CREDATE,‘mm‘),‘06‘,a.INNUM,0)) innum6,
sum(decode(to_char(a.CREDATE,‘mm‘),‘07‘,a.INNUM,0)) innum7,
sum(decode(to_char(a.CREDATE,‘mm‘),‘08‘,a.INNUM,0)) innum8,
sum(decode(to_char(a.CREDATE,‘mm‘),‘09‘,a.INNUM,0)) innum9,
sum(decode(to_char(a.CREDATE,‘mm‘),‘10‘,a.INNUM,0)) innum10,
sum(decode(to_char(a.CREDATE,‘mm‘),‘11‘,a.INNUM,0)) innum11,
sum(decode(to_char(a.CREDATE,‘mm‘),‘12‘,a.INNUM,0)) innum12,
sum(decode(to_char(a.CREDATE,‘mm‘),‘01‘,((select APRICE from UNMATERIAL
where KEYID=a.MATERIAL_ID)* a.INNUM),0)) inmoney1,
sum(decode(to_char(a.CREDATE,‘mm‘),‘02‘,((select APRICE from UNMATERIAL
where KEYID=a.MATERIAL_ID)* a.INNUM),0)) inmoney2,
sum(decode(to_char(a.CREDATE,‘mm‘),‘03‘,((select APRICE from UNMATERIAL
where KEYID=a.MATERIAL_ID)* a.INNUM),0)) inmoney3,
sum(decode(to_char(a.CREDATE,‘mm‘),‘04‘,((select APRICE from UNMATERIAL
where KEYID=a.MATERIAL_ID)* a.INNUM),0)) inmoney4,
sum(decode(to_char(a.CREDATE,‘mm‘),‘05‘,((select APRICE from UNMATERIAL
where KEYID=a.MATERIAL_ID)* a.INNUM),0)) inmoney5,
sum(decode(to_char(a.CREDATE,‘mm‘),‘06‘,((select APRICE from UNMATERIAL
where KEYID=a.MATERIAL_ID)* a.INNUM),0)) inmoney6,
sum(decode(to_char(a.CREDATE,‘mm‘),‘07‘,((select APRICE from UNMATERIAL
where KEYID=a.MATERIAL_ID)* a.INNUM),0)) inmoney7,
sum(decode(to_char(a.CREDATE,‘mm‘),‘08‘,((select APRICE from UNMATERIAL
where KEYID=a.MATERIAL_ID)* a.INNUM),0)) inmoney8,
sum(decode(to_char(a.CREDATE,‘mm‘),‘09‘,((select APRICE from UNMATERIAL
where KEYID=a.MATERIAL_ID)* a.INNUM),0)) inmoney9,
sum(decode(to_char(a.CREDATE,‘mm‘),‘10‘,((select APRICE from UNMATERIAL
where KEYID=a.MATERIAL_ID)* a.INNUM),0)) inmoney10,
sum(decode(to_char(a.CREDATE,‘mm‘),‘11‘,((select APRICE from UNMATERIAL
where KEYID=a.MATERIAL_ID)* a.INNUM),0)) inmoney11,
sum(decode(to_char(a.CREDATE,‘mm‘),‘12‘,((select APRICE from UNMATERIAL
where KEYID=a.MATERIAL_ID)* a.INNUM),0)) inmoney12
from UNMATERIAL_Order a ,UNMATERIAL b
where to_char(a.CREDATE,‘yyyy‘)=to_char(sysdate,‘yyyy‘) and a.MATERIAL_id
= b.MATERIAL_id and a.OUTOFSTORAGETYPE=‘入库‘
group by to_char(a.CREDATE,‘yyyy-
mm‘),b.MATERIALname,b.GOODSPEC,b.SAFETYONE
select * from V_Logistics_month where CREDATE=‘2016‘
----(round((a.QSSL/a.NUMS)*100,2))||‘%‘,0))
drop view V_Logistics_month
create view V_Logistics_month
as
select
b.COMPNAME, --物流公司
c.GENSTORAGENAME, --仓库名称
d.PEONAME, --往来单位名称
to_char(a.CREDATE,‘yyyy‘) as CREDATE,
sum(decode(to_char(a.CREDATE,‘mm‘),‘01‘,a.NUMS,0)) NUM1,
sum(decode(to_char(a.CREDATE,‘mm‘),‘02‘,a.NUMS,0)) NUM2,
sum(decode(to_char(a.CREDATE,‘mm‘),‘03‘,a.NUMS,0)) NUM3,
sum(decode(to_char(a.CREDATE,‘mm‘),‘04‘,a.NUMS,0)) NUM4,
sum(decode(to_char(a.CREDATE,‘mm‘),‘05‘,a.NUMS,0)) NUM5,
sum(decode(to_char(a.CREDATE,‘mm‘),‘06‘,a.NUMS,0)) NUM6,
sum(decode(to_char(a.CREDATE,‘mm‘),‘07‘,a.NUMS,0)) NUM7,
sum(decode(to_char(a.CREDATE,‘mm‘),‘08‘,a.NUMS,0)) NUM8,
sum(decode(to_char(a.CREDATE,‘mm‘),‘09‘,a.NUMS,0)) NUM9,
sum(decode(to_char(a.CREDATE,‘mm‘),‘10‘,a.NUMS,0)) NUM10,
sum(decode(to_char(a.CREDATE,‘mm‘),‘11‘,a.NUMS,0)) NUM11,
sum(decode(to_char(a.CREDATE,‘mm‘),‘12‘,a.NUMS,0)) NUM12,
sum(decode(to_char(a.CREDATE,‘mm‘),‘01‘,trunc((A.QSSL/a.NUMS)*100,2),0))
WORNNUM1,
sum(decode(to_char(a.CREDATE,‘mm‘),‘02‘,trunc((A.QSSL/a.NUMS)*100,2),0))
WORNNUM2,
sum(decode(to_char(a.CREDATE,‘mm‘),‘03‘,trunc((A.QSSL/a.NUMS)*100,2),0))
WORNNUM3,
sum(decode(to_char(a.CREDATE,‘mm‘),‘04‘,trunc((A.QSSL/a.NUMS)*100,2),0))
WORNNUM4,
sum(decode(to_char(a.CREDATE,‘mm‘),‘05‘,trunc((A.QSSL/a.NUMS)*100,2),0))
WORNNUM5,
sum(decode(to_char(a.CREDATE,‘mm‘),‘06‘,trunc((A.QSSL/a.NUMS)*100,2),0))
WORNNUM6,
sum(decode(to_char(a.CREDATE,‘mm‘),‘07‘,trunc((A.QSSL/a.NUMS)*100,2),0))
WORNNUM7,
sum(decode(to_char(a.CREDATE,‘mm‘),‘08‘,trunc((A.QSSL/a.NUMS)*100,2),0))
WORNNUM8,
sum(decode(to_char(a.CREDATE,‘mm‘),‘08‘,trunc((A.QSSL/a.NUMS)*100,2),0))
WORNNUM9,
sum(decode(to_char(a.CREDATE,‘mm‘),‘10‘,trunc((A.QSSL/a.NUMS)*100,2),0))
WORNNUM10,
sum(decode(to_char(a.CREDATE,‘mm‘),‘11‘,trunc((A.QSSL/a.NUMS)*100,2),0))
WORNNUM11,
sum(decode(to_char(a.CREDATE,‘mm‘),‘12‘,trunc((A.QSSL/a.NUMS)*100,2),0))
WORNNUM12
FROM RK a,LOGICOMPNAME_NEW b,NEWGENSTORAGE c,PROVIDEINFONEW d
where a.WLDW=b.Keyid and a.NEWGENSTORAGE_ID=c.Keyid and a.PEOID=d.Keyid
group by to_char(a.CREDATE,‘yyyy‘),b.COMPNAME,c.GENSTORAGENAME,d.PEONAME
select * from V_Logistics_year where CREDATE=‘2016‘
----(round((a.QSSL/a.NUMS)*100,2))||‘%‘,0))
drop view V_Logistics_year
create view V_Logistics_year
as
select
b.COMPNAME, --物流公司
c.GENSTORAGENAME, --仓库名称
d.PEONAME, --往来单位名称
to_char(a.CREDATE,‘yyyy‘) as CREDATE,
sum(decode(to_char(a.CREDATE,‘yyyy‘),to_char(a.CREDATE,‘yyyy‘),a.NUMS,0))
YEARNUMS,
sum(decode(to_char(a.CREDATE,‘yyyy‘),to_char(a.CREDATE,‘yyyy‘),trunc
((A.QSSL/a.NUMS)*100,2),0)) YEARWORNNUM
FROM RK a,LOGICOMPNAME_NEW b,NEWGENSTORAGE c,PROVIDEINFONEW d
where a.WLDW=b.Keyid and a.NEWGENSTORAGE_ID=c.Keyid and a.PEOID=d.Keyid
group by to_char(a.CREDATE,‘yyyy‘),b.COMPNAME,c.GENSTORAGENAME,d.PEONAME
标签:lte const dba rnn mount next arch ber money
原文地址:http://www.cnblogs.com/dfxyw/p/6413961.html