create or replace view v_allinfo_stat_by_site as
          select a.*,b.BLACK_COUNT,b.WHITE_COUNT,b.GRAY_COUNT,b.AUTHOR_COUNT,group_count,audit_count,vblog_org_count,valbum_count from v_video_stat_by_site a,
          v_vblogger_stat_by_site b,
          (select count(*) group_count,site_id from vblogger_group group by site_id) c ,
          (select count(*) audit_count,site_id from audit_web_video group by site_id) d ,
          (select count(*) vblog_org_count,site_id from vblogger_org group by site_id) e ,
          (select count(*) valbum_count,site_id from valbum group by site_id) f
           where a.site_id = b.site_id(+) and
           a.site_id = c.site_id(+) and
           a.site_id = d.site_id(+) and
           a.site_id = e.site_id(+) and
           a.site_id = f.site_id(+)
           order by a.all_count desc;


          c,d,e也是相當于視圖
          a、b本身就是視圖


          存儲過程
          create or replace procedure UPDATE_VBLOGGER_MONTHLY_WEEKLY as
            v_now_date  NUMBER;
          begin
          --按月統計
             SELECT TO_NUMBER(TO_CHAR(sysdate,'YYYYMM'))INTO v_now_date FROM dual;
             update vblogger v set v.monthly_video_count=0;
             update vblogger v set v.weekly_video_count=0;
          COMMIT;   
             update vblogger v set v.monthly_video_count=(select count(*) from web_video w where GET_TIME_FORMAT(1,w.video_day)=v_now_date and v.site_id=w.site_id and v.name=w.video_author group by w.site_id,w.video_author) ;
          --按周統計
               SELECT TO_NUMBER(TO_CHAR(sysdate,'YYYYFMWW'))INTO v_now_date FROM dual;
               update vblogger v set v.weekly_video_count=(select count(*) from web_video w where GET_TIME_FORMAT(3,w.video_day)=v_now_date and v.site_id=w.site_id and v.name=w.video_author group by w.site_id,w.video_author) ;
          COMMIT;
          end;

          posts - 103, comments - 104, trackbacks - 0, articles - 5

          Copyright © Robert Su

          主站蜘蛛池模板: 蒲江县| 珠海市| 舟山市| 资阳市| 饶河县| 贵定县| 丹阳市| 五大连池市| 镇沅| 甘泉县| 富源县| 景德镇市| 疏附县| 政和县| 晋城| 石门县| 红桥区| 合作市| 滁州市| 安顺市| 卢龙县| 阳山县| 曲松县| 临江市| 东台市| 绵阳市| 镇安县| 大埔区| 花莲县| 兴和县| 林甸县| 彭泽县| 永安市| 永丰县| 南汇区| 台东县| 全州县| 遂川县| 闻喜县| 永寿县| 岳阳市|