财务报表权限+费用下钻功能
This commit is contained in:
parent
d873fbe08e
commit
cfde02b97e
@ -12,6 +12,7 @@
|
|||||||
<file url="file://$PROJECT_DIR$/FineReport/财务主题/报表/费用/1_1_1OA表单下钻.sql" dialect="PostgreSQL" />
|
<file url="file://$PROJECT_DIR$/FineReport/财务主题/报表/费用/1_1_1OA表单下钻.sql" dialect="PostgreSQL" />
|
||||||
<file url="file://$PROJECT_DIR$/FineReport/财务主题/报表/费用/1_1财务凭证下钻.sql" dialect="PostgreSQL" />
|
<file url="file://$PROJECT_DIR$/FineReport/财务主题/报表/费用/1_1财务凭证下钻.sql" dialect="PostgreSQL" />
|
||||||
<file url="file://$PROJECT_DIR$/FineReport/财务主题/报表/费用/4-财务费用汇总表.sql" dialect="PostgreSQL" />
|
<file url="file://$PROJECT_DIR$/FineReport/财务主题/报表/费用/4-财务费用汇总表.sql" dialect="PostgreSQL" />
|
||||||
|
<file url="file://$PROJECT_DIR$/FineReport/销售主题/报表/销售业绩/城市单元业绩达成.sql" dialect="PostgreSQL" />
|
||||||
<file url="file://$PROJECT_DIR$/FineReport/销售主题/报表/销售业绩/酱酒计划执行表.sql" dialect="PostgreSQL" />
|
<file url="file://$PROJECT_DIR$/FineReport/销售主题/报表/销售业绩/酱酒计划执行表.sql" dialect="PostgreSQL" />
|
||||||
<file url="file://$PROJECT_DIR$/FineReport/销售主题/报表/销售业绩/销售业绩组合统计表.sql" dialect="PostgreSQL" />
|
<file url="file://$PROJECT_DIR$/FineReport/销售主题/报表/销售业绩/销售业绩组合统计表.sql" dialect="PostgreSQL" />
|
||||||
<file url="file://$PROJECT_DIR$/FineReport/销售主题/报表/销售业绩/销售指标月度汇总.sql" dialect="PostgreSQL" />
|
<file url="file://$PROJECT_DIR$/FineReport/销售主题/报表/销售业绩/销售指标月度汇总.sql" dialect="PostgreSQL" />
|
||||||
|
@ -3,10 +3,23 @@ WITH corp AS (
|
|||||||
corp_code,
|
corp_code,
|
||||||
corp_name
|
corp_name
|
||||||
FROM
|
FROM
|
||||||
"dwr"."dim_corp"
|
"dwr"."dim_corp" a
|
||||||
WHERE
|
WHERE
|
||||||
corp_type = '实体'
|
corp_type = '实体'
|
||||||
AND (parent_corp_code LIKE '02%' OR corp_code = '0301')
|
AND (parent_corp_code LIKE '02%' OR corp_code = '0301')
|
||||||
|
AND exists (
|
||||||
|
select
|
||||||
|
1
|
||||||
|
from
|
||||||
|
dm.dm_bi_user_permisson
|
||||||
|
where
|
||||||
|
bi_user = '${fine_username}'
|
||||||
|
and per_model IN ('all','sal')
|
||||||
|
and (
|
||||||
|
is_all = 1
|
||||||
|
OR per_code = a.corp_code
|
||||||
|
)
|
||||||
|
)
|
||||||
${IF(LEN(sCorp )!=0," AND corp_code IN ('"+ sCorp +"')", "")}
|
${IF(LEN(sCorp )!=0," AND corp_code IN ('"+ sCorp +"')", "")}
|
||||||
),
|
),
|
||||||
base_info AS (
|
base_info AS (
|
||||||
|
@ -3,10 +3,23 @@ WITH corp AS (
|
|||||||
corp_code,
|
corp_code,
|
||||||
corp_name
|
corp_name
|
||||||
FROM
|
FROM
|
||||||
"dwr"."dim_corp"
|
"dwr"."dim_corp" a
|
||||||
WHERE
|
WHERE
|
||||||
corp_type = '实体'
|
corp_type = '实体'
|
||||||
AND (parent_corp_code LIKE '02%' OR corp_code = '0301')
|
AND (parent_corp_code LIKE '02%' OR corp_code = '0301')
|
||||||
|
AND exists (
|
||||||
|
select
|
||||||
|
1
|
||||||
|
from
|
||||||
|
dm.dm_bi_user_permisson
|
||||||
|
where
|
||||||
|
bi_user = '${fine_username}'
|
||||||
|
and per_model IN ('all','sal')
|
||||||
|
and (
|
||||||
|
is_all = 1
|
||||||
|
OR per_code = a.corp_code
|
||||||
|
)
|
||||||
|
)
|
||||||
${IF(LEN(sCorp )!=0," AND corp_code IN ('"+ sCorp +"')", "")}
|
${IF(LEN(sCorp )!=0," AND corp_code IN ('"+ sCorp +"')", "")}
|
||||||
),
|
),
|
||||||
base_info AS (
|
base_info AS (
|
||||||
@ -115,11 +128,11 @@ WITH corp AS (
|
|||||||
,SUM(refund_amt) AS "退税金额"
|
,SUM(refund_amt) AS "退税金额"
|
||||||
from dwi.dwi_fim_tax_payed t1
|
from dwi.dwi_fim_tax_payed t1
|
||||||
JOIN corp t2 ON t1.corp_code = t2.corp_code
|
JOIN corp t2 ON t1.corp_code = t2.corp_code
|
||||||
WHERE stat_date <= '${CONCATENATE(sEnd_mon,"-01 00:00:00")}'
|
WHERE bill_status='已匹配'
|
||||||
|
AND stat_date <= '${CONCATENATE(sEnd_mon,"-01 00:00:00")}'
|
||||||
AND stat_date >= '${CONCATENATE(sStart_mon,"-01 00:00:00")}'
|
AND stat_date >= '${CONCATENATE(sStart_mon,"-01 00:00:00")}'
|
||||||
GROUP By tax_name
|
GROUP By tax_name
|
||||||
)fin3
|
)fin3
|
||||||
on fin0.税种 = fin3.税种
|
on fin0.税种 = fin3.税种
|
||||||
ORDER BY
|
ORDER BY
|
||||||
fin0.seq
|
fin0.seq
|
||||||
;
|
|
@ -9,6 +9,19 @@ WITH corp AS (
|
|||||||
WHERE
|
WHERE
|
||||||
t1.corp_type = '实体'
|
t1.corp_type = '实体'
|
||||||
AND (t1.parent_corp_code LIKE '02%' OR t1.corp_code = '0301')
|
AND (t1.parent_corp_code LIKE '02%' OR t1.corp_code = '0301')
|
||||||
|
AND exists (
|
||||||
|
select
|
||||||
|
1
|
||||||
|
from
|
||||||
|
dm.dm_bi_user_permisson
|
||||||
|
where
|
||||||
|
bi_user = '${fine_username}'
|
||||||
|
and per_model IN ('all','sal')
|
||||||
|
and (
|
||||||
|
is_all = 1
|
||||||
|
OR per_code = t1.corp_code
|
||||||
|
)
|
||||||
|
)
|
||||||
${IF(LEN(sCorp )!=0," AND t1.corp_code IN ('"+ sCorp +"')", "")}
|
${IF(LEN(sCorp )!=0," AND t1.corp_code IN ('"+ sCorp +"')", "")}
|
||||||
|
|
||||||
),
|
),
|
||||||
|
@ -2,9 +2,22 @@ WITH corp AS (
|
|||||||
SELECT
|
SELECT
|
||||||
corp_code -- 公司编码
|
corp_code -- 公司编码
|
||||||
,corp_name -- 公司名称
|
,corp_name -- 公司名称
|
||||||
FROM dwr.dim_corp
|
FROM dwr.dim_corp a
|
||||||
WHERE corp_type = '实体'
|
WHERE corp_type = '实体'
|
||||||
AND (parent_corp_code LIKE '02%' OR corp_code = '0301')
|
AND (parent_corp_code LIKE '02%' OR corp_code = '0301')
|
||||||
|
AND exists (
|
||||||
|
select
|
||||||
|
1
|
||||||
|
from
|
||||||
|
dm.dm_bi_user_permisson
|
||||||
|
where
|
||||||
|
bi_user = '${fine_username}'
|
||||||
|
and per_model IN ('all','sal')
|
||||||
|
and (
|
||||||
|
is_all = 1
|
||||||
|
OR per_code = a.corp_code
|
||||||
|
)
|
||||||
|
)
|
||||||
${IF(LEN(sCorp)!=0," AND corp_code IN ('"+ sCorp +"')", "")}
|
${IF(LEN(sCorp)!=0," AND corp_code IN ('"+ sCorp +"')", "")}
|
||||||
),
|
),
|
||||||
base_info_curr AS (
|
base_info_curr AS (
|
||||||
|
@ -2,15 +2,28 @@ WITH corp AS (
|
|||||||
SELECT
|
SELECT
|
||||||
corp_code -- 公司编码
|
corp_code -- 公司编码
|
||||||
,corp_name -- 公司名称
|
,corp_name -- 公司名称
|
||||||
FROM dwr.dim_corp
|
FROM dwr.dim_corp a
|
||||||
WHERE corp_type = '实体'
|
WHERE corp_type = '实体'
|
||||||
AND (parent_corp_code LIKE '02%' OR corp_code = '0301')
|
AND (parent_corp_code LIKE '02%' OR corp_code = '0301')
|
||||||
|
AND exists (
|
||||||
|
select
|
||||||
|
1
|
||||||
|
from
|
||||||
|
dm.dm_bi_user_permisson
|
||||||
|
where
|
||||||
|
bi_user = '${fine_username}'
|
||||||
|
and per_model IN ('all','sal')
|
||||||
|
and (
|
||||||
|
is_all = 1
|
||||||
|
OR per_code = a.corp_code
|
||||||
|
)
|
||||||
|
)
|
||||||
${IF(LEN(sCorp)!=0," AND corp_code IN ('"+ sCorp +"')", "")}
|
${IF(LEN(sCorp)!=0," AND corp_code IN ('"+ sCorp +"')", "")}
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
bill_date -- 制单日期
|
TO_CHAR(bill_date, 'YYYY-MM-DD') AS bill_date -- 制单日期
|
||||||
,audit_date -- 终审日期
|
,TO_CHAR(audit_date, 'YYYY-MM-DD') AS audit_date -- 终审日期
|
||||||
,pay_time -- 付款时间
|
,TO_CHAR(pay_time, 'YYYY-MM-DD HH24:MI:SS') AS pay_time -- 付款时间
|
||||||
,bill_code -- 单据号
|
,bill_code -- 单据号
|
||||||
,bill_status -- 单据状态
|
,bill_status -- 单据状态
|
||||||
,budget_code -- 预算编号
|
,budget_code -- 预算编号
|
||||||
@ -34,11 +47,11 @@ SELECT
|
|||||||
FROM dwi.dwi_fim_oa_payment
|
FROM dwi.dwi_fim_oa_payment
|
||||||
WHERE corp_code in(SELECT corp_code FROM corp)
|
WHERE corp_code in(SELECT corp_code FROM corp)
|
||||||
AND bill_date >= CONCAT('${sStart_mon}','-01')
|
AND bill_date >= CONCAT('${sStart_mon}','-01')
|
||||||
AND bill_date <= CONCAT('${sEnd_mon}','-01')
|
AND bill_date <= CONCAT('${sEnd_mon}','-30')
|
||||||
${if(len(sBill)=0,"","AND bill_code = '" + sBill +"'")}
|
${if(len(sBill)=0,"","AND bill_code = '" + sBill +"'")}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
CONCAT('数据更新日期:',LEFT(MAX(update_time),19)) AS update_time
|
CONCAT('数据更新时间:',LEFT(MAX(update_time),19)) AS update_time
|
||||||
FROM dwi.dwi_fim_oa_payment
|
FROM dwi.dwi_fim_oa_payment
|
||||||
|
@ -2,13 +2,26 @@ WITH corp AS (
|
|||||||
SELECT
|
SELECT
|
||||||
corp_code -- 公司编码
|
corp_code -- 公司编码
|
||||||
,corp_name -- 公司名称
|
,corp_name -- 公司名称
|
||||||
FROM dwr.dim_corp
|
FROM dwr.dim_corp a
|
||||||
WHERE corp_type = '实体'
|
WHERE corp_type = '实体'
|
||||||
AND (parent_corp_code LIKE '02%' OR corp_code = '0301')
|
AND (parent_corp_code LIKE '02%' OR corp_code = '0301')
|
||||||
|
AND exists (
|
||||||
|
select
|
||||||
|
1
|
||||||
|
from
|
||||||
|
dm.dm_bi_user_permisson
|
||||||
|
where
|
||||||
|
bi_user = '${fine_username}'
|
||||||
|
and per_model IN ('all','sal')
|
||||||
|
and (
|
||||||
|
is_all = 1
|
||||||
|
OR per_code = a.corp_code
|
||||||
|
)
|
||||||
|
)
|
||||||
${IF(LEN(sCorp)!=0," AND corp_code IN ('"+ sCorp +"')", "")}
|
${IF(LEN(sCorp)!=0," AND corp_code IN ('"+ sCorp +"')", "")}
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
bill_date -- 制单日期
|
TO_CHAR(bill_date, 'YYYY-MM-DD') AS bill_date -- 制单日期
|
||||||
,bill_emp_code -- 制单人工号
|
,bill_emp_code -- 制单人工号
|
||||||
,corp_code -- 公司编码
|
,corp_code -- 公司编码
|
||||||
,acnt_book_name -- 主体账簿
|
,acnt_book_name -- 主体账簿
|
||||||
@ -28,23 +41,14 @@ SELECT
|
|||||||
,src_bill_codes -- 来源单据号
|
,src_bill_codes -- 来源单据号
|
||||||
,acnt_date -- 记账日期
|
,acnt_date -- 记账日期
|
||||||
FROM dwi.dwi_fim_voucher
|
FROM dwi.dwi_fim_voucher
|
||||||
where subject_code like '6601%'
|
where corp_code in(SELECT corp_code FROM corp)
|
||||||
and corp_code in(SELECT corp_code FROM corp)
|
|
||||||
${if(len(sBill)=0," ","AND src_bill_codes = '" + sBill + "'")}
|
${if(len(sBill)=0," ","AND src_bill_codes = '" + sBill + "'")}
|
||||||
AND acnt_year = LEFT('${sStart_mon}',4)
|
AND acnt_year = LEFT('${sStart_mon}',4)
|
||||||
AND acnt_mon >= RIGHT('${sStart_mon}',2)
|
AND acnt_mon >= RIGHT('${sStart_mon}',2)
|
||||||
AND acnt_mon <= RIGHT('${sEnd_mon}',2)
|
AND acnt_mon <= RIGHT('${sEnd_mon}',2)
|
||||||
-- AND acnt_mon <= '${FORMAT(sStart_mon,"MM")}'
|
|
||||||
-- ${switch(sCalcType
|
|
||||||
-- ,"m","AND concat(acnt_year,'-',acnt_mon) <= '" + sQueryDate + "' AND concat(acnt_year,'-',acnt_mon) >= '" + sQueryStartDate + "'"
|
|
||||||
-- ,"y","AND concat(acnt_year,'-',acnt_mon) <= '" + sQueryDate + "' AND concat(acnt_year,'-',acnt_mon) >= '" + sQueryStartDate + "'"
|
|
||||||
-- )}
|
|
||||||
|
|
||||||
-- ${switch(sCalcType
|
|
||||||
-- ,"m","AND acnt_year = '" + YEAR(sStart_mon) + "' AND acnt_mon = '" + FORMAT(sStart_mon,"MM") + "'"
|
|
||||||
-- ,"y","AND acnt_year = '" + YEAR(sStart_mon) + "' AND acnt_mon = '" + FORMAT(sStart_mon,"MM") + "'"
|
|
||||||
-- )}
|
|
||||||
|
|
||||||
|
${if(sFee_type='销售费用',"","/*")}
|
||||||
|
AND subject_code like '6601%'
|
||||||
${nvl(switch(sSubject
|
${nvl(switch(sSubject
|
||||||
,"0000","AND subject_code like '6601%' AND (subject_code not like '660114%'
|
,"0000","AND subject_code like '6601%' AND (subject_code not like '660114%'
|
||||||
AND subject_code not like '660127%'
|
AND subject_code not like '660127%'
|
||||||
@ -60,8 +64,53 @@ AND acnt_mon <= RIGHT('${sEnd_mon}',2)
|
|||||||
)"
|
)"
|
||||||
,"660114,660127","AND (subject_code like '660114%' or subject_code like '660127%')")
|
,"660114,660127","AND (subject_code like '660114%' or subject_code like '660127%')")
|
||||||
,"and subject_code like '" + sSubject +"%'")}
|
,"and subject_code like '" + sSubject +"%'")}
|
||||||
|
${if(sFee_type='销售费用',"","*/")}
|
||||||
|
|
||||||
|
|
||||||
|
${if(sFee_type='管理费用',"","/*")}
|
||||||
|
AND subject_code like '6602%'
|
||||||
|
|
||||||
|
${if(sSubject='合计',"",nvl(switch(sSubject
|
||||||
|
,"0000","AND subject_code NOT LIKE '660297%'
|
||||||
|
AND subject_code NOT LIKE '660219%'
|
||||||
|
AND subject_code NOT LIKE '660289%'
|
||||||
|
AND subject_code NOT LIKE '660243%'
|
||||||
|
AND subject_code NOT LIKE '660226%'
|
||||||
|
AND subject_code NOT LIKE '660234%'
|
||||||
|
AND subject_code NOT LIKE '660221%'
|
||||||
|
AND subject_code NOT LIKE '660227%'
|
||||||
|
AND subject_code NOT LIKE '660232%'
|
||||||
|
AND subject_code NOT LIKE '660233%'
|
||||||
|
AND subject_code NOT LIKE '660231%'
|
||||||
|
AND subject_code NOT LIKE '660273%'
|
||||||
|
AND subject_code NOT LIKE '660290%'
|
||||||
|
AND subject_code NOT LIKE '660237%'
|
||||||
|
AND subject_code NOT LIKE '660287%'
|
||||||
|
AND subject_code NOT LIKE '660228%'"
|
||||||
|
)
|
||||||
|
,"and subject_code like '" + sSubject +"%'"))}
|
||||||
|
${if(sFee_type='管理费用',"","*/")}
|
||||||
|
|
||||||
|
|
||||||
|
${if(sFee_type='研发费用',"","/*")}
|
||||||
|
AND subject_code like '6604%'
|
||||||
|
${if(sSubject='合计',"",nvl(switch(sSubject
|
||||||
|
,"0000","AND subject_code NOT like '660401%'
|
||||||
|
AND subject_code NOT like '660403%'
|
||||||
|
AND subject_code NOT like '660409%'
|
||||||
|
AND subject_code NOT like '660408%'
|
||||||
|
AND subject_code NOT like '660402%'"
|
||||||
|
)
|
||||||
|
,"and subject_code like '" + sSubject +"%'"))}
|
||||||
|
|
||||||
|
${if(sFee_type='研发费用',"","*/")}
|
||||||
|
|
||||||
|
|
||||||
|
${if(sFee_type='财务费用',"","/*")}
|
||||||
|
AND subject_code like '6603%'
|
||||||
|
${if(sSubject='000000',"","AND subject_code like '" + sSubject + "%'")}
|
||||||
|
${if(sFee_type='财务费用',"","*/")}
|
||||||
|
|
||||||
-- ======================================
|
-- ======================================
|
||||||
-- 数据更新时间
|
-- 数据更新时间
|
||||||
-- ======================================
|
-- ======================================
|
||||||
@ -70,7 +119,7 @@ AND acnt_mon <= RIGHT('${sEnd_mon}',2)
|
|||||||
|
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
CONCAT('数据更新日期:',LEFT(MAX(update_time),19)) AS update_time
|
CONCAT('数据更新时间:',LEFT(MAX(update_time),19)) AS update_time
|
||||||
FROM dwi.dwi_fim_voucher
|
FROM dwi.dwi_fim_voucher
|
||||||
where subject_code like '6601%'
|
where subject_code like '6601%'
|
||||||
|
|
||||||
|
@ -2,9 +2,22 @@ WITH corp AS (
|
|||||||
SELECT
|
SELECT
|
||||||
corp_code -- 公司编码
|
corp_code -- 公司编码
|
||||||
,corp_name -- 公司名称
|
,corp_name -- 公司名称
|
||||||
FROM dwr.dim_corp
|
FROM dwr.dim_corp a
|
||||||
WHERE corp_type = '实体'
|
WHERE corp_type = '实体'
|
||||||
AND (parent_corp_code LIKE '02%' OR corp_code = '0301')
|
AND (parent_corp_code LIKE '02%' OR corp_code = '0301')
|
||||||
|
AND exists (
|
||||||
|
select
|
||||||
|
1
|
||||||
|
from
|
||||||
|
dm.dm_bi_user_permisson
|
||||||
|
where
|
||||||
|
bi_user = '${fine_username}'
|
||||||
|
and per_model IN ('all','sal')
|
||||||
|
and (
|
||||||
|
is_all = 1
|
||||||
|
OR per_code = a.corp_code
|
||||||
|
)
|
||||||
|
)
|
||||||
${IF(LEN(sCorp)!=0," AND corp_code IN ('"+ sCorp +"')", "")}
|
${IF(LEN(sCorp)!=0," AND corp_code IN ('"+ sCorp +"')", "")}
|
||||||
),
|
),
|
||||||
base_info_curr AS (
|
base_info_curr AS (
|
||||||
@ -35,6 +48,7 @@ WITH corp AS (
|
|||||||
-- 本期统计
|
-- 本期统计
|
||||||
SELECT
|
SELECT
|
||||||
'职工薪酬' AS subject_name -- 科目名称
|
'职工薪酬' AS subject_name -- 科目名称
|
||||||
|
,'660297' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -44,6 +58,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'折旧费' AS subject_name -- 科目名称
|
'折旧费' AS subject_name -- 科目名称
|
||||||
|
,'660219' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -53,6 +68,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'物料消耗' AS subject_name -- 科目名称
|
'物料消耗' AS subject_name -- 科目名称
|
||||||
|
,'660289' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -62,6 +78,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'存货损耗' AS subject_name -- 科目名称
|
'存货损耗' AS subject_name -- 科目名称
|
||||||
|
,'660243' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -71,6 +88,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'办公费' AS subject_name -- 科目名称
|
'办公费' AS subject_name -- 科目名称
|
||||||
|
,'660226' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -80,6 +98,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'咨询服务费' AS subject_name -- 科目名称
|
'咨询服务费' AS subject_name -- 科目名称
|
||||||
|
,'660234' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -89,6 +108,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'无形资产摊销' AS subject_name -- 科目名称
|
'无形资产摊销' AS subject_name -- 科目名称
|
||||||
|
,'660221' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -98,6 +118,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'差旅费' AS subject_name -- 科目名称
|
'差旅费' AS subject_name -- 科目名称
|
||||||
|
,'660227' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -107,6 +128,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'物业管理费' AS subject_name -- 科目名称
|
'物业管理费' AS subject_name -- 科目名称
|
||||||
|
,'660232' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -116,6 +138,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'水电气费' AS subject_name -- 科目名称
|
'水电气费' AS subject_name -- 科目名称
|
||||||
|
,'660233' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -125,6 +148,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'车辆使用费' AS subject_name -- 科目名称
|
'车辆使用费' AS subject_name -- 科目名称
|
||||||
|
,'660231' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -134,6 +158,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'业务招待费' AS subject_name -- 科目名称
|
'业务招待费' AS subject_name -- 科目名称
|
||||||
|
,'660273' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -143,6 +168,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'使用权资产摊销' AS subject_name -- 科目名称
|
'使用权资产摊销' AS subject_name -- 科目名称
|
||||||
|
,'660290' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -152,6 +178,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'租赁费' AS subject_name -- 科目名称
|
'租赁费' AS subject_name -- 科目名称
|
||||||
|
,'660237' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -161,6 +188,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'通讯费' AS subject_name -- 科目名称
|
'通讯费' AS subject_name -- 科目名称
|
||||||
|
,'660287' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -170,6 +198,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'会议费' AS subject_name -- 科目名称
|
'会议费' AS subject_name -- 科目名称
|
||||||
|
,'660228' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -179,6 +208,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'其他' AS subject_name -- 科目名称
|
'其他' AS subject_name -- 科目名称
|
||||||
|
,'0000' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -205,6 +235,7 @@ WITH corp AS (
|
|||||||
-- 上期统计
|
-- 上期统计
|
||||||
SELECT
|
SELECT
|
||||||
'职工薪酬' AS subject_name -- 科目名称
|
'职工薪酬' AS subject_name -- 科目名称
|
||||||
|
,'660297' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -214,6 +245,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'折旧费' AS subject_name -- 科目名称
|
'折旧费' AS subject_name -- 科目名称
|
||||||
|
,'660219' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -223,6 +255,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'物料消耗' AS subject_name -- 科目名称
|
'物料消耗' AS subject_name -- 科目名称
|
||||||
|
,'660289' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -232,6 +265,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'存货损耗' AS subject_name -- 科目名称
|
'存货损耗' AS subject_name -- 科目名称
|
||||||
|
,'660243' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -241,6 +275,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'办公费' AS subject_name -- 科目名称
|
'办公费' AS subject_name -- 科目名称
|
||||||
|
,'660226' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -250,6 +285,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'咨询服务费' AS subject_name -- 科目名称
|
'咨询服务费' AS subject_name -- 科目名称
|
||||||
|
,'660234' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -259,6 +295,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'无形资产摊销' AS subject_name -- 科目名称
|
'无形资产摊销' AS subject_name -- 科目名称
|
||||||
|
,'660221' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -268,6 +305,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'差旅费' AS subject_name -- 科目名称
|
'差旅费' AS subject_name -- 科目名称
|
||||||
|
,'660227' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -277,6 +315,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'物业管理费' AS subject_name -- 科目名称
|
'物业管理费' AS subject_name -- 科目名称
|
||||||
|
,'660232' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -286,6 +325,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'水电气费' AS subject_name -- 科目名称
|
'水电气费' AS subject_name -- 科目名称
|
||||||
|
,'660233' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -295,6 +335,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'车辆使用费' AS subject_name -- 科目名称
|
'车辆使用费' AS subject_name -- 科目名称
|
||||||
|
,'660231' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -304,6 +345,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'业务招待费' AS subject_name -- 科目名称
|
'业务招待费' AS subject_name -- 科目名称
|
||||||
|
,'660273' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -313,6 +355,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'使用权资产摊销' AS subject_name -- 科目名称
|
'使用权资产摊销' AS subject_name -- 科目名称
|
||||||
|
,'660290' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -322,6 +365,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'租赁费' AS subject_name -- 科目名称
|
'租赁费' AS subject_name -- 科目名称
|
||||||
|
,'660237' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -331,6 +375,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'通讯费' AS subject_name -- 科目名称
|
'通讯费' AS subject_name -- 科目名称
|
||||||
|
,'660287' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -340,6 +385,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'会议费' AS subject_name -- 科目名称
|
'会议费' AS subject_name -- 科目名称
|
||||||
|
,'660228' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -349,6 +395,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'其他' AS subject_name -- 科目名称
|
'其他' AS subject_name -- 科目名称
|
||||||
|
,'0000' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -375,12 +422,13 @@ WITH corp AS (
|
|||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
subject_name AS subject_name -- 科目名称
|
subject_name AS subject_name -- 科目名称
|
||||||
|
,subject_code AS subject_code -- 科目编码
|
||||||
,IFNULL(SUM(debit_amt_m ) / 10000,0) AS debit_amt_m -- 借方金额_当月累计
|
,IFNULL(SUM(debit_amt_m ) / 10000,0) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,IFNULL(SUM(debit_amt_y ) / 10000,0) AS debit_amt_y -- 借方金额_当年累计
|
,IFNULL(SUM(debit_amt_y ) / 10000,0) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,IFNULL(SUM(debit_amt_last_m) / 10000,0) AS debit_amt_last_m -- 借方金额_上年同期
|
,IFNULL(SUM(debit_amt_last_m) / 10000,0) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
,IFNULL(SUM(debit_amt_last_y) / 10000,0) AS debit_amt_last_y -- 借方金额_上年累计
|
,IFNULL(SUM(debit_amt_last_y) / 10000,0) AS debit_amt_last_y -- 借方金额_上年累计
|
||||||
FROM subject_result
|
FROM subject_result
|
||||||
GROUP BY
|
GROUP BY
|
||||||
subject_name
|
subject_name,subject_code
|
||||||
ORDER BY
|
ORDER BY
|
||||||
DECODE(subject_name,'职工薪酬','a','折旧费','b','物料消耗','c','存货损耗','d','办公费','e','咨询服务费','f','无形资产摊销','g','差旅费','h','物业管理费','i','水电气费','j','车辆使用费','k','业务招待费','l','使用权资产摊销','m','租赁费','n','通讯费','o','会议费','p','其他','q')
|
DECODE(subject_name,'职工薪酬','a','折旧费','b','物料消耗','c','存货损耗','d','办公费','e','咨询服务费','f','无形资产摊销','g','差旅费','h','物业管理费','i','水电气费','j','车辆使用费','k','业务招待费','l','使用权资产摊销','m','租赁费','n','通讯费','o','会议费','p','其他','q')
|
@ -2,9 +2,22 @@ WITH corp AS (
|
|||||||
SELECT
|
SELECT
|
||||||
corp_code -- 公司编码
|
corp_code -- 公司编码
|
||||||
,corp_name -- 公司名称
|
,corp_name -- 公司名称
|
||||||
FROM dwr.dim_corp
|
FROM dwr.dim_corp a
|
||||||
WHERE corp_type = '实体'
|
WHERE corp_type = '实体'
|
||||||
AND (parent_corp_code LIKE '02%' OR corp_code = '0301')
|
AND (parent_corp_code LIKE '02%' OR corp_code = '0301')
|
||||||
|
AND exists (
|
||||||
|
select
|
||||||
|
1
|
||||||
|
from
|
||||||
|
dm.dm_bi_user_permisson
|
||||||
|
where
|
||||||
|
bi_user = '${fine_username}'
|
||||||
|
and per_model IN ('all','sal')
|
||||||
|
and (
|
||||||
|
is_all = 1
|
||||||
|
OR per_code = a.corp_code
|
||||||
|
)
|
||||||
|
)
|
||||||
${IF(LEN(sCorp)!=0," AND corp_code IN ('"+ sCorp +"')", "")}
|
${IF(LEN(sCorp)!=0," AND corp_code IN ('"+ sCorp +"')", "")}
|
||||||
),
|
),
|
||||||
base_info_curr AS (
|
base_info_curr AS (
|
||||||
@ -35,6 +48,7 @@ WITH corp AS (
|
|||||||
-- 本期统计
|
-- 本期统计
|
||||||
SELECT
|
SELECT
|
||||||
'材料费' AS subject_name -- 科目名称
|
'材料费' AS subject_name -- 科目名称
|
||||||
|
,'660401' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -44,6 +58,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'职工薪酬' AS subject_name -- 科目名称
|
'职工薪酬' AS subject_name -- 科目名称
|
||||||
|
,'660403' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -53,6 +68,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'差旅费' AS subject_name -- 科目名称
|
'差旅费' AS subject_name -- 科目名称
|
||||||
|
,'660409' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -62,6 +78,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'加工费' AS subject_name -- 科目名称
|
'加工费' AS subject_name -- 科目名称
|
||||||
|
,'660408' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -71,6 +88,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'技术服务费' AS subject_name -- 科目名称
|
'技术服务费' AS subject_name -- 科目名称
|
||||||
|
,'660402' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -80,6 +98,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'其他' AS subject_name -- 科目名称
|
'其他' AS subject_name -- 科目名称
|
||||||
|
,'0000' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -94,6 +113,7 @@ WITH corp AS (
|
|||||||
-- 上期统计
|
-- 上期统计
|
||||||
SELECT
|
SELECT
|
||||||
'材料费' AS subject_name -- 科目名称
|
'材料费' AS subject_name -- 科目名称
|
||||||
|
,'660401' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -103,6 +123,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'职工薪酬' AS subject_name -- 科目名称
|
'职工薪酬' AS subject_name -- 科目名称
|
||||||
|
,'660403' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -112,6 +133,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'差旅费' AS subject_name -- 科目名称
|
'差旅费' AS subject_name -- 科目名称
|
||||||
|
,'660409' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -121,6 +143,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'加工费' AS subject_name -- 科目名称
|
'加工费' AS subject_name -- 科目名称
|
||||||
|
,'660408' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -130,6 +153,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'技术服务费' AS subject_name -- 科目名称
|
'技术服务费' AS subject_name -- 科目名称
|
||||||
|
,'660402' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -139,6 +163,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'其他' AS subject_name -- 科目名称
|
'其他' AS subject_name -- 科目名称
|
||||||
|
,'0000' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -152,12 +177,13 @@ WITH corp AS (
|
|||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
subject_name AS subject_name -- 科目名称
|
subject_name AS subject_name -- 科目名称
|
||||||
|
,subject_code AS subject_code -- 科目编码
|
||||||
,IFNULL(SUM(debit_amt_m ) / 10000,0) AS debit_amt_m -- 借方金额_当月累计
|
,IFNULL(SUM(debit_amt_m ) / 10000,0) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,IFNULL(SUM(debit_amt_y ) / 10000,0) AS debit_amt_y -- 借方金额_当年累计
|
,IFNULL(SUM(debit_amt_y ) / 10000,0) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,IFNULL(SUM(debit_amt_last_m) / 10000,0) AS debit_amt_last_m -- 借方金额_上年同期
|
,IFNULL(SUM(debit_amt_last_m) / 10000,0) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
,IFNULL(SUM(debit_amt_last_y) / 10000,0) AS debit_amt_last_y -- 借方金额_上年累计
|
,IFNULL(SUM(debit_amt_last_y) / 10000,0) AS debit_amt_last_y -- 借方金额_上年累计
|
||||||
FROM subject_result
|
FROM subject_result
|
||||||
GROUP BY
|
GROUP BY
|
||||||
subject_name
|
subject_name,subject_code
|
||||||
ORDER BY
|
ORDER BY
|
||||||
DECODE(subject_name,'材料费','a','职工薪酬','b','差旅费','c','加工费','d','技术服务费','e','其他','f')
|
DECODE(subject_name,'材料费','a','职工薪酬','b','差旅费','c','加工费','d','技术服务费','e','其他','f')
|
@ -2,9 +2,22 @@ WITH corp AS (
|
|||||||
SELECT
|
SELECT
|
||||||
corp_code -- 公司编码
|
corp_code -- 公司编码
|
||||||
,corp_name -- 公司名称
|
,corp_name -- 公司名称
|
||||||
FROM dwr.dim_corp
|
FROM dwr.dim_corp a
|
||||||
WHERE corp_type = '实体'
|
WHERE corp_type = '实体'
|
||||||
AND (parent_corp_code LIKE '02%' OR corp_code = '0301')
|
AND (parent_corp_code LIKE '02%' OR corp_code = '0301')
|
||||||
|
AND exists (
|
||||||
|
select
|
||||||
|
1
|
||||||
|
from
|
||||||
|
dm.dm_bi_user_permisson
|
||||||
|
where
|
||||||
|
bi_user = '${fine_username}'
|
||||||
|
and per_model IN ('all','sal')
|
||||||
|
and (
|
||||||
|
is_all = 1
|
||||||
|
OR per_code = a.corp_code
|
||||||
|
)
|
||||||
|
)
|
||||||
${IF(LEN(sCorp)!=0," AND corp_code IN ('"+ sCorp +"')", "")}
|
${IF(LEN(sCorp)!=0," AND corp_code IN ('"+ sCorp +"')", "")}
|
||||||
),
|
),
|
||||||
base_info_curr AS (
|
base_info_curr AS (
|
||||||
@ -35,6 +48,7 @@ WITH corp AS (
|
|||||||
-- 本期统计
|
-- 本期统计
|
||||||
SELECT
|
SELECT
|
||||||
'利息支出' AS subject_name -- 科目名称
|
'利息支出' AS subject_name -- 科目名称
|
||||||
|
,'660301' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -44,6 +58,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'减:利息收入' AS subject_name -- 科目名称
|
'减:利息收入' AS subject_name -- 科目名称
|
||||||
|
,'660302' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) * -1 AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) * -1 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_m) * -1 AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_m) * -1 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -53,6 +68,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'汇兑损益' AS subject_name -- 科目名称
|
'汇兑损益' AS subject_name -- 科目名称
|
||||||
|
,'660303' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -62,6 +78,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'金融机构手续费' AS subject_name -- 科目名称
|
'金融机构手续费' AS subject_name -- 科目名称
|
||||||
|
,'660304' AS subject_code -- 科目编码
|
||||||
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
,SUM(debit_amt_m) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
,SUM(debit_amt_y) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
,0 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -92,6 +109,7 @@ WITH corp AS (
|
|||||||
-- 上期统计
|
-- 上期统计
|
||||||
SELECT
|
SELECT
|
||||||
'利息支出' AS subject_name -- 科目名称
|
'利息支出' AS subject_name -- 科目名称
|
||||||
|
,'660301' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -101,6 +119,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'减:利息收入' AS subject_name -- 科目名称
|
'减:利息收入' AS subject_name -- 科目名称
|
||||||
|
,'660302' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) * -1 AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) * -1 AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -110,6 +129,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'汇兑损益' AS subject_name -- 科目名称
|
'汇兑损益' AS subject_name -- 科目名称
|
||||||
|
,'660303' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -119,6 +139,7 @@ WITH corp AS (
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'金融机构手续费' AS subject_name -- 科目名称
|
'金融机构手续费' AS subject_name -- 科目名称
|
||||||
|
,'660304' AS subject_code -- 科目编码
|
||||||
,0 AS debit_amt_m -- 借方金额_当月累计
|
,0 AS debit_amt_m -- 借方金额_当月累计
|
||||||
,0 AS debit_amt_y -- 借方金额_当年累计
|
,0 AS debit_amt_y -- 借方金额_当年累计
|
||||||
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
,SUM(debit_amt_m) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -149,6 +170,7 @@ WITH corp AS (
|
|||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
subject_name
|
subject_name
|
||||||
|
,subject_code
|
||||||
,debit_amt_m -- 借方金额_当月累计
|
,debit_amt_m -- 借方金额_当月累计
|
||||||
,debit_amt_y -- 借方金额_当年累计
|
,debit_amt_y -- 借方金额_当年累计
|
||||||
,debit_amt_last_m -- 借方金额_上年同期
|
,debit_amt_last_m -- 借方金额_上年同期
|
||||||
@ -157,18 +179,20 @@ FROM
|
|||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
subject_name AS subject_name -- 科目名称
|
subject_name AS subject_name -- 科目名称
|
||||||
|
,subject_code AS subject_code -- 科目编码
|
||||||
,IFNULL(SUM(debit_amt_m ) / 10000,0) AS debit_amt_m -- 借方金额_当月累计
|
,IFNULL(SUM(debit_amt_m ) / 10000,0) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,IFNULL(SUM(debit_amt_y ) / 10000,0) AS debit_amt_y -- 借方金额_当年累计
|
,IFNULL(SUM(debit_amt_y ) / 10000,0) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,IFNULL(SUM(debit_amt_last_m) / 10000,0) AS debit_amt_last_m -- 借方金额_上年同期
|
,IFNULL(SUM(debit_amt_last_m) / 10000,0) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
,IFNULL(SUM(debit_amt_last_y) / 10000,0) AS debit_amt_last_y -- 借方金额_上年累计
|
,IFNULL(SUM(debit_amt_last_y) / 10000,0) AS debit_amt_last_y -- 借方金额_上年累计
|
||||||
FROM subject_result
|
FROM subject_result
|
||||||
GROUP BY
|
GROUP BY
|
||||||
subject_name
|
subject_name,subject_code
|
||||||
-- ORDER BY
|
-- ORDER BY
|
||||||
-- DECODE(subject_name,'利息支出','a','减:利息收入','b','汇兑损益','c','金融机构手续费','d','其他','e')
|
-- DECODE(subject_name,'利息支出','a','减:利息收入','b','汇兑损益','c','金融机构手续费','d','其他','e')
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'合计' AS subject_name -- 科目名称
|
'合计' AS subject_name -- 科目名称
|
||||||
|
,'000000' AS subject_code -- 科目编码
|
||||||
,IFNULL(SUM(CASE WHEN subject_name = '减:利息收入' THEN -1 * debit_amt_m ELSE debit_amt_m END) / 10000,0) AS debit_amt_m -- 借方金额_当月累计
|
,IFNULL(SUM(CASE WHEN subject_name = '减:利息收入' THEN -1 * debit_amt_m ELSE debit_amt_m END) / 10000,0) AS debit_amt_m -- 借方金额_当月累计
|
||||||
,IFNULL(SUM(CASE WHEN subject_name = '减:利息收入' THEN -1 * debit_amt_y ELSE debit_amt_y END) / 10000,0) AS debit_amt_y -- 借方金额_当年累计
|
,IFNULL(SUM(CASE WHEN subject_name = '减:利息收入' THEN -1 * debit_amt_y ELSE debit_amt_y END) / 10000,0) AS debit_amt_y -- 借方金额_当年累计
|
||||||
,IFNULL(SUM(CASE WHEN subject_name = '减:利息收入' THEN -1 * debit_amt_last_m ELSE debit_amt_last_m END ) / 10000,0) AS debit_amt_last_m -- 借方金额_上年同期
|
,IFNULL(SUM(CASE WHEN subject_name = '减:利息收入' THEN -1 * debit_amt_last_m ELSE debit_amt_last_m END ) / 10000,0) AS debit_amt_last_m -- 借方金额_上年同期
|
||||||
|
90
FineReport/销售主题/报表/销售业绩/城市单元业绩达成.sql
Normal file
90
FineReport/销售主题/报表/销售业绩/城市单元业绩达成.sql
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
-- *****************************
|
||||||
|
-- 创建人员: 杨坤安
|
||||||
|
-- 创建时间: 202401120
|
||||||
|
-- 功能描述: 原报表名称: 04城市单元主要指标达成
|
||||||
|
-- *****************************
|
||||||
|
|
||||||
|
|
||||||
|
-- ======================================
|
||||||
|
-- 08销售指标达成(看板)
|
||||||
|
-- ======================================
|
||||||
|
|
||||||
|
select a.pk,
|
||||||
|
a.stat_date,
|
||||||
|
a.indi_type,
|
||||||
|
a.bu_code,
|
||||||
|
o.dept_name as bu_name,
|
||||||
|
a.region_code,
|
||||||
|
d.secd_dept_name as region_name,
|
||||||
|
a.office_code,
|
||||||
|
d.thrd_dept_name as office_name,
|
||||||
|
a.city_unit_code,
|
||||||
|
d.dept_name as city_unit_name,
|
||||||
|
pv.town_name as province_name,
|
||||||
|
cit.town_name as city_name,
|
||||||
|
a.deal_code,
|
||||||
|
deal.deal_name,
|
||||||
|
a.src_deal_code,
|
||||||
|
a.deal_type,
|
||||||
|
a.product_code,
|
||||||
|
a.num_bu,
|
||||||
|
a.num_region,
|
||||||
|
a.num_office,
|
||||||
|
a.num_city_unit,
|
||||||
|
a.num_dealer,
|
||||||
|
a.amt_bu,
|
||||||
|
a.amt_region,
|
||||||
|
a.amt_office,
|
||||||
|
a.amt_city_unit,
|
||||||
|
a.amt_dealer,
|
||||||
|
a.update_time,
|
||||||
|
a.is_new_dealer
|
||||||
|
from dm.dm_sal_indicator_day a
|
||||||
|
left join dwr.dim_department d on d.dept_code=a.city_unit_code
|
||||||
|
left join dwr.dim_dealer deal on a.deal_code=deal.deal_code
|
||||||
|
left join dwr.dim_department o on o.dept_code=a.bu_code
|
||||||
|
left join dwr.dim_product po on a.product_code=po.product_code
|
||||||
|
left join (select city_unit_code,
|
||||||
|
max(province_code) as province_code,
|
||||||
|
max(city_code) as city_code
|
||||||
|
from dwr.dim_dealer_administer
|
||||||
|
where enabled_status=1
|
||||||
|
group by city_unit_code) are on a.city_unit_code=are.city_unit_code
|
||||||
|
left join dwr.dim_area pv on nvl(a.province_code,are.province_code)=pv.town_code
|
||||||
|
left join dwr.dim_area cit on nvl(a.city_code,are.city_code)=cit.town_code
|
||||||
|
left join dwr.dim_department dd on (case when
|
||||||
|
a.indi_type in ('融资未填仓','已填仓未下单','未下单往来余额','费用余额')
|
||||||
|
then a.bu_code else po.bu_code end)=dd.dept_code
|
||||||
|
where stat_date>=date'2020-01-01'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- ======================================
|
||||||
|
-- 05城市单元销售指标达成
|
||||||
|
-- ======================================
|
||||||
|
|
||||||
|
|
||||||
|
select
|
||||||
|
stat_date
|
||||||
|
,indi_type
|
||||||
|
,cp_region_code
|
||||||
|
,cp_region_name
|
||||||
|
,bu_code
|
||||||
|
,bu_name
|
||||||
|
,region_code
|
||||||
|
,region_name
|
||||||
|
,office_code
|
||||||
|
,office_name
|
||||||
|
,city_unit_code
|
||||||
|
,city_unit_name
|
||||||
|
,deal_type
|
||||||
|
,province
|
||||||
|
,city
|
||||||
|
-- 年度
|
||||||
|
-- 月度
|
||||||
|
-- 季度
|
||||||
|
,amt_cityunit -- 金额
|
||||||
|
from dm.v_sal_indicator_cityunit
|
@ -317,3 +317,5 @@ SELECT MAX(update_time) AS update_time FROM dwr.fact_sal_deliver -- dm.v_ag_sal_
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT MAX(update_time) AS update_time FROM dwr.fact_sal_dealer_stock -- dm.v_ag_sal_deal_stock -- 实物库存
|
SELECT MAX(update_time) AS update_time FROM dwr.fact_sal_dealer_stock -- dm.v_ag_sal_deal_stock -- 实物库存
|
||||||
)T
|
)T
|
||||||
|
|
||||||
|
-- 使用 : dm.dm_sal_indicator_day 去掉目标
|
Loading…
Reference in New Issue
Block a user