惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
Cisco Talos Blog
Cisco Talos Blog
C
Check Point Blog
博客园_首页
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Martin Fowler
Martin Fowler
Recorded Future
Recorded Future
S
Security @ Cisco Blogs
L
LINUX DO - 最新话题
博客园 - 司徒正美
P
Privacy International News Feed
G
Google Developers Blog
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
K
Kaspersky official blog
I
InfoQ
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Webroot Blog
Webroot Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
大猫的无限游戏
大猫的无限游戏
D
Docker
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
Microsoft Azure Blog
Microsoft Azure Blog
Spread Privacy
Spread Privacy
量子位
H
Hacker News: Front Page
Simon Willison's Weblog
Simon Willison's Weblog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
SecWiki News
SecWiki News
S
Security Affairs
Latest news
Latest news
人人都是产品经理
人人都是产品经理
C
CERT Recently Published Vulnerability Notes
S
Security Archives - TechRepublic
V
Visual Studio Blog
T
Troy Hunt's Blog
S
Secure Thoughts
F
Fortinet All Blogs
V
V2EX
The Register - Security
The Register - Security
J
Java Code Geeks
MongoDB | Blog
MongoDB | Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

博客园 - 左少白

oracle 找回DROP掉的表 求解,工作流点通过时,弹出窗口让用户录入审核意见 oracle 游标 c# 多态 sqlserver 按五分钟分组 c# 继承 查询行转列 SqlParameter序列化的问题 oracle oracle trunc (date,dd )函数 oracle 游标 对象集合转换为datatable 用C# 正则 提取HTML标签中的值? oracle decode 与 case when ,空的处理 oracle select for update sql1 Oracle Index 相關知識 玩转DevExpress.XtraGrid.view.gridview oracle索引 在Oracle中进行大小写不敏感的查询2
同期进度,完成率
左少白 · 2010-02-21 · via 博客园 - 左少白

PROCEDURE P_DailyReport

            (v_StatisticsDate IN varchar2, v_BranchFlag IN VARCHAR2,cur_name OUT t_cursor)

IS

   i_year  INTEGER :=0;--年份

   i_month INTEGER  :=0;--月份

   i_day   INTEGER  :=0;--天数

   i_monthdays INTEGER :=0;--本月天数

   i_alldays   INTEGER  :=0;--全年天数

   d_firstday DATE;--本月第一天

   d_yearfirstday DATE;--本年第一天

   i_pastdays INTEGER  :=0;--当年已过天数

   d_lastyearfirstday DATE;--去年第一天

   d_lasttoday DATE;--去年今天

   d_StatisticsDate DATE;

BEGIN

    i_year  :=to_number(substr(v_statisticsdate,1,4));

    i_month :=to_number(substr(v_statisticsdate,6,2));

    i_day   :=to_number(substr(v_statisticsdate,9,2));

    d_StatisticsDate:=to_date(v_StatisticsDate,'yyyy-mm-dd');

    --本月第一天,总天数

    SELECT MIN(thedate),MAX(theday)

      INTO d_firstday,i_monthdays

      FROM dim_date

     WHERE theyear=i_year AND themonth=i_month;

     --全年天数

     SELECT COUNT(1),MIN(thedate)

       INTO i_alldays,d_yearfirstday

       FROM dim_date

      WHERE theyear=i_year;

     --当年已过天数

     SELECT COUNT(1)

       INTO i_pastdays

       FROM dim_date

      WHERE theyear=i_year AND thedate<=d_StatisticsDate;

     --去年第一天

     SELECT MIN(thedate)

       INTO d_lastyearfirstday

       FROM dim_date

      WHERE theyear=i_year-1;

     --去年今天

     SELECT thedate

       INTO d_lasttoday

       FROM dim_date

      WHERE theyear=i_year-1 AND themonth=i_month AND theday=i_day;

OPEN cur_name FOR

     SELECT  c.branchabbr,d.TARGET,

             round(d.TARGET/i_alldays*i_monthdays,2) monthtarget, --月指标

             round(SUM(e.amount)/100000000,4) xshje,

             round(SUM(e.amount)/(d.TARGET/i_alldays*i_day*100000000),4),--当月进度

             round(SUM(f.amount)/100000000,4) ndxshje,

             round(SUM(f.amount)/(d.TARGET/i_alldays*i_pastdays*100000000),4),--年同期进度

             round(d.TARGET/i_alldays*i_monthdays-SUM(e.amount)/100000000,4),  --月度差额

             round(SUM(g.amount)/100000000,4),

             round((SUM(f.amount)- SUM(g.amount))/ SUM(g.amount),4)

       FROM ( SELECT a.branchabbr,a.branchflag,b.branchflag branchflag3

                FROM(SELECT branchabbr,branchflag

                       FROM t_jzt_common_branch

                      WHERE isactive=1

                        AND branchlevel=2 AND branchflag<>'ZDA' AND branchflag<>'FDY'

                     ) a

                INNER JOIN(SELECT branchflag,higherbranchflag

                             FROM t_jzt_common_branch

                            WHERE isactive=1 AND branchflag<>'ZDA'

                           )b ON a.branchflag=b.higherbranchflag

            ) c

       LEFT JOIN  t_report_TARGET d ON d.statisticsdate=i_year

                                    AND d.branchflag=c.branchflag

                                    AND d.TARGETType='销售指标'

       LEFT JOIN (SELECT branchflag,sum(amount) amount--月度

                    FROM t_bi_dailysalereport

                   WHERE orderdate >=d_firstday AND orderdate<=d_StatisticsDate

                   GROUP BY branchflag

                 ) e ON e.branchflag=c.branchflag3

       LEFT JOIN (SELECT branchflag,sum(amount) amount--年度

                    FROM t_bi_dailysalereport

                   WHERE orderdate>=d_yearfirstday AND orderdate<=d_StatisticsDate

                   GROUP BY branchflag

                 ) f ON f.branchflag=c.branchflag3

       LEFT JOIN (SELECT branchflag,sum(amount) amount --去年

                    FROM t_bi_dailysalereport

                   WHERE orderdate >=d_lastyearfirstday AND orderdate<=d_lasttoday

                   GROUP BY branchflag

                 )g ON g.branchflag=c.branchflag3

       GROUP BY c.branchabbr,d.TARGET

       ORDER BY c.branchabbr,d.TARGET;

END P_DailyReport;