pdf_code/zzb_data_prod/处理历史数据/12.sql

269 lines
7.6 KiB
MySQL
Raw Normal View History

2025-09-02 15:23:55 +08:00
SELECT * from ori_measure_list where file_id=201928 and measure_name like "%营业收入%";
SELECT * from ori_measure_list where file_id=39302 and measure_name like "%经营活动现金流%" order by page_number;
SELECT * from ori_measure_list where file_id=201876 and measure_name like "%经营活动现金流%" order by page_number;
SELECT * from measure_list where file_id=201876;
SELECT * from word_measure_parse_process where file_id=201834;
SELECT * from pdf_parse_process where file_id=201844 and content like '%"table"%' ORDER BY page_num;
SELECT * from measure_parse_process where file_id=201844 and content like '%经营活动%';
SELECT * from word_measure_parse_process where file_id=201876 and content like '%经营活动%'
SELECT * from measure_list where file_id=201844 and measure_name like "%经营活动现金流%";
SELECT * from measure_list where file_id=201876 and measure_name like "%经营活动现金流%";
##问题1 page——num 11 这个 word 没存
SELECT * from word_parse_process where file_id=201837 and content like '%"table"%' ORDER BY page_num;
DELETE from word_parse_process where file_id=201834 ;
DELETE from ori_measure_list where file_id=201834 ;
SELECT * from report_check order by create_time desc ;
select count(*) from word_measure_parse_process where file_id = 593;
select count(*) from word_measure_parse_process where file_id = 201834;
SELECT ori_measure_name,measure_name,distance,ori_measure_id,measure_id FROM measure_config_third_quarter
where year = 2023
SELECT * from pdf_text_info where file_id=201844;
SELECT * FROM measure_black_list where isdel = 0 and find_in_set(3,flag) and find_in_set(2023,year) and measure_name like "%经营活动%";
SELECT * from measure_parser_info where file_id=201928;
SELECT * from word_measure_parse_process where file_id=201928;
select * from word_parse_process WHERE file_id = '201928' order by page_num;
SELECT * from report_check WHERE id = "40925";
select
InnerCode
,CompanyCode
,LPAD(SecuCode,6,'0') as SecuCode
,ChiName
from secumain s
where ListedState=1
and ListedSector in (1,2,6,7,8)
and SecuCategory in (1,41)
and SecuMarket in (18,83,90)
SELECT * from third_measure_data where SecuCode like '688032' ;
set @year = "2023";
set @enddate = "2023-6-30 00:00:00";
set @InfoPublDate = '2024-9-30 00:00:00';
-- 年报是0 半年报是1
set @report_type = 1;
SELECT * from lc_stibmaindata WHERE CompanyCode = '19767000' and IfMerged='1' and EndDate=@enddate and InfoPublDate < @InfoPublDate;
SELECT * from lc_stibincomestate WHERE CompanyCode = '19767000' and IfMerged='1' and EndDate=@enddate and InfoPublDate < @InfoPublDate;
SELECT * from lc_stibbalancesheet WHERE CompanyCode = '19767000' and IfMerged='1' and EndDate=@enddate and InfoPublDate < @InfoPublDate;
drop table if exists third_quarter_external_data_tmp_pre;
create table third_quarter_external_data_tmp_pre
as
select distinct @year as year
,@report_type as report_type
,t1.*
,Infopubldate
,InfoPublDate_end
,OperatingReenue
,NPFromParentCompanyOwners
,NetProfitCut
,NetOperateCashFlow
,NetFinanceCashFlow
,NetInvestCashFlow
,NonRecurringProfitLoss
,BasicEPS
,DilutedEPS
,WROE
,WROECut
,TotalAssets
,CashEquivalents
,AccountReceivable
,Inventories
,TotalFixedAsset
,TConstruInProcess
,GoodWill
,ShortTermLoan
,AccountsPayable
,ContractLiability
,LongtermLoan
,AccountingStandards
,OperatingExpense
,OperatingCost
,AdministrationExpense
,FinancialExpense
,RAndD
from
(
select
InnerCode
,CompanyCode
,LPAD(SecuCode,6,'0') as SecuCode
,ChiName
from secumain s
where ListedState=1
and ListedSector in (1,2,6,7,8)
and SecuCategory in (1,41)
and SecuMarket in (18,83,90)
)t1
left join
(
select
CompanyCode
,Infopubldate
,OperatingReenue
, null as NPFromParentCompanyOwners
,NetProfitCut
,NetOperateCashFlow
,NetFinanceCashFlow
,NetInvestCashFlow
,NonRecurringProfitLoss
,BasicEPS
,DilutedEPS
,WROE
,WROECut
from
(
SELECT *
FROM (SELECT b.*
,@rownum := @rownum+1
,IF(@pdept = b.CompanyCode, @rank := @rank + 1, @rank := 1) AS rank_num
,@pdept := b.CompanyCode
FROM (SELECT * FROM lc_stibmaindata a
where EndDate=@enddate and InfoPublDate < @InfoPublDate
ORDER BY a.CompanyCode, a.InfoPublDate DESC) b
-- 初始化自定义变量值
,(SELECT @rownum :=0, @pdept := NULL, @rank:=0) c
-- 该排序必须,否则结果会不对
ORDER BY b.CompanyCode, b.InfoPublDate DESC) result
order by CompanyCode, rank_num
)t where t.rank_num=1
)t2
on t1.CompanyCode = t2.CompanyCode
left join
(
select
EndDate,
InfoSourceCode as InfoSource,
CompanyCode,
TotalAssets
from
(
SELECT *
FROM (SELECT b.*
,@rownum := @rownum+1
,IF(@pdept = b.CompanyCode, @rank := @rank + 1, @rank := 1) AS rank_num
,@pdept := b.CompanyCode
FROM (SELECT * FROM lc_stibmaindata a
where EndDate=@enddate and InfoPublDate < @InfoPublDate
ORDER BY a.CompanyCode, a.InfoPublDate DESC) b
-- 初始化自定义变量值
,(SELECT @rownum :=0, @pdept := NULL, @rank:=0) c
-- 该排序必须,否则结果会不对
ORDER BY b.CompanyCode, b.InfoPublDate DESC) result
order by CompanyCode, rank_num
)t where t.rank_num=1
)t5
on t1.CompanyCode = t5.CompanyCode
left join
(
select
EndDate,
InfoPublDate as InfoPublDate_end,
InfoSourceCode as InfoSource,
CompanyCode,
CashEquivalents,
AccountReceivable,
Inventories,
TotalFixedAsset,
TConstruInProcess,
GoodWill,
ShortTermLoan,
AccountsPayable,
ContractLiability,
LongtermLoan
from
(
SELECT *
FROM (SELECT b.*
,@rownum := @rownum+1
,IF(@pdept = b.CompanyCode, @rank := @rank + 1, @rank := 1) AS rank_num
,@pdept := b.CompanyCode
FROM (SELECT * FROM lc_stibbalancesheet a
where IfMerged =1
and EndDate=@enddate and InfoPublDate < @InfoPublDate
ORDER BY a.CompanyCode, a.InfoPublDate DESC) b
-- 初始化自定义变量值
,(SELECT @rownum :=0, @pdept := NULL, @rank:=0) c
-- 该排序必须,否则结果会不对
ORDER BY b.CompanyCode, b.InfoPublDate DESC) result
order by CompanyCode, rank_num
)t where t.rank_num=1
)t4
on t1.CompanyCode = t4.CompanyCode
left join
(
select
CompanyCode
,EndDate
,null as AccountingStandards
,OperatingExpense
,OperatingCost
,AdministrationExpense
,FinancialExpense
,RAndD
from
(
SELECT *
FROM (SELECT b.*
,@rownum := @rownum+1
,IF(@pdept = b.CompanyCode, @rank := @rank + 1, @rank := 1) AS rank_num
,@pdept := b.CompanyCode
FROM (SELECT * FROM lc_stibincomestate a
where IfMerged =1
and EndDate=@enddate and InfoPublDate < @InfoPublDate
ORDER BY a.CompanyCode, a.InfoPublDate DESC) b
-- 初始化自定义变量值
,(SELECT @rownum :=0, @pdept := NULL, @rank:=0) c
-- 该排序必须,否则结果会不对
ORDER BY b.CompanyCode, b.InfoPublDate DESC) result
order by CompanyCode, rank_num
)t where t.rank_num=1
)t3
on t1.CompanyCode = t3.CompanyCode
;
SELECT * from third_quarter_external_data_tmp_pre where CompanyCode = '19767000';
SELECT * from third_measure_data where SecuCode like '000937%' and year = '2021' and report_type = '0';
SELECT * from lc_balancesheetall where CompanyCode = '171402' and IfMerged = '1';
SELECT * from lc_maindatanew where CompanyCode = '503' and EndDate like '%2021-12-31%' ;
SELECT * from secumain where SecuCode = '300432'
delete from third_measure_data where report_type
SELECT * from model_ip;