`
pingwei000
  • 浏览: 60941 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

报表数据采集procedure_备份

SNS 
阅读更多
-- Procedure "sns_login_reg" DDL

CREATE DEFINER=`root`@`localhost` PROCEDURE `sns_login_reg`(in start_day varchar(255),in end_day varchar(255))
begin

declare counts int;

declare next_id int default 1;

declare currentday varchar(255);

declare all_user int;

declare new_booker int;

declare old_sns int;

declare new_sns int;

declare today date;

declare days int;

CREATE TEMPORARY TABLE user_login_reg(

row_id int auto_increment primary key ,

rang_day varchar(255) ,

sum_user int,

new_user_booker int,

old_user int,

new_user_sns int

);



set today= start_day;

if(end_day>start_day)

then

SELECT DATEDIFF(end_day,start_day) into days;

while days>0

do

insert into user_login_reg(rang_day) values(today);

set today=ADDDATE(today,1);

set days=days-1;

end while;

end if;

select count(row_id) into counts from user_login_reg;

while counts>0 do

select rang_day into currentday from user_login_reg where row_id=next_id;

select count(distinct(uid)) into all_user from sns.uchome_actionlog where substring(dateline,1,10)=currentday and uid!=-1 and uid !=cid;

select count(uid) into new_booker from sns.uchome_space where substring(FROM_UNIXTIME(dateline),1,10) =currentday and productId=1 ;

select count(uid) into new_sns from sns.uchome_space where substring(FROM_UNIXTIME(dateline),1,10) =currentday and productId=1000 ;



/*select count(uid) from (select uid,dateline from sns.uchome_space where uid in (select distinct(uid) from sns.uchome_actionlog where substring(dateline,1,10)=currentdayand uid!=-1)) as old_user where substring(from_unixtime(old_user.dateline),1,10)!=currentday */

/*select count(distinct(uid)) into old_sns from sns.uchome_actionlog where substring(dateline,1,10)=currentday and uid!=-1 and uid not in(select uid from sns.uchome_space where substring(from_unixtime(dateline),1,10)=currentday);*/

set old_sns=all_user-new_booker-new_sns;

update user_login_reg set sum_user=all_user,new_user_booker=new_booker,old_user=old_sns,new_user_sns=new_sns where rang_day=currentday;

set next_id=next_id+1;

set counts=counts-1;

end while;

select * from user_login_reg;

drop table user_login_reg;

end;
***************************************************************************************************************


-- Procedure "sns_statistics_pv" DDL

CREATE DEFINER=`root`@`localhost` PROCEDURE `sns_statistics_pv`(in end_day varchar(255))
begin

declare counts int;

declare next_id int default 1;

declare currentday varchar(255);

declare pv int;

declare login_user_pv int;

declare anonymous_user_pv int;

declare app_pv int;

declare login_user_app_pv int;

declare anonymous_user_app_pv int;

CREATE TEMPORARY TABLE statistics4pv(

row_id int auto_increment primary key ,

rang_day varchar(255) ,

pv_count int,

login_average_pv int,
anonymous_average_pv int,

app_pv_count int,

app_login_average_pv int,

app_anonymous_average_pv int

);

insert into statistics4pv(rang_day) select distinct(substring(dateline,1,10)) from sns.uchome_actionlog where dateline<end_day;

select count(row_id) into counts from statistics4pv;

while counts>0 do

select rang_day into currentday from statistics4pv where row_id=next_id;

select count(logid) into pv from sns.uchome_actionlog where substring(dateline,1,10)=currentday;

select ifnull(count(logid) /count(distinct(uid)),'0') into login_user_pv from sns.uchome_actionlog where substring(dateline,1,10)=currentday and uid!=-1 ;

select ifnull(count(logid) /count(distinct(cid)),'0') into anonymous_user_pv from sns.uchome_actionlog where substring(dateline,1,10)=currentday and uid=-1 ;

select count(logid) into app_pv from sns.uchome_actionlog where substring(dateline,1,10)=currentday and actionid>60 and actionid<72;

select ifnull(count(logid) /count(distinct(uid)),'0') into login_user_app_pv from sns.uchome_actionlog where substring(dateline,1,10)=currentday and actionid>60 and actionid<72 and uid!=-1 ;

select ifnull(count(logid) /count(distinct(cid)),'0') into anonymous_user_app_pv from sns.uchome_actionlog where substring(dateline,1,10)=currentday and actionid>60 and actionid<72 and uid =-1 ;

update statistics4pv set pv_count=pv,login_average_pv=login_user_pv,anonymous_average_pv=anonymous_user_pv,app_pv_count=app_pv,app_login_average_pv=login_user_app_pv,app_anonymous_average_pv=anonymous_user_app_pv where rang_day=currentday;

set next_id=next_id+1;

set counts=counts-1;

end while;

select * from statistics4pv;

drop table statistics4pv;

end;


 
分享到:
评论

相关推荐

    Keysight_PCIe_5_CEM_Test_Procedure_TX_v0.9.pdf

    Keysight_PCIe_5_CEM_Test_Procedure_TX_v0.9

    RapidIO_Bring-Up_Procedure_on_PowerQUICC_III

    RapidIO_Bring-Up_Procedure_on_PowerQUICC_III,The MPC8540 and MPC8560 PowerQUICC III™ processors have an 8-bit parallel RapidIO interface. This document provides guidance in the basic use of this ...

    Oracle-procedure.rar_oracle_oracle procedure_oracle 存储过程

    在Oracle数据库中,存储过程(Procedure)是核心的编程组件,它允许开发人员编写和存储可重复使用的SQL和PL/SQL代码块。这篇教程将深入探讨Oracle存储过程的概念、创建、调用以及其在数据库管理中的应用。 一、存储...

    CPSC-CH-C1001-09.4_Standard_Operating_Procedure_for_Determinatio

    标题 "CPSC-CH-C1001-09.4_Standard_Operating_Procedure_for_Determinatio" 暗示我们正在处理一个关于标准操作程序(SOP)的文档,具体是针对邻苯二甲酸盐(phthalates)的测定。邻苯二甲酸盐是一类常用的塑化剂,...

    67506283BP-procedure_cs_bp_基追踪_压缩感知_

    标题"67506283BP-procedure_cs_bp_基追踪_压缩感知_"表明这是一个关于使用BP算法实现压缩感知的程序流程或者步骤。压缩包内的"BP procedure"可能是包含实现这一算法的MATLAB代码文件,可能包括主函数、辅助函数以及...

    FANUC-30iB-All-in-one-Data-Procedure_30ib_fanuc_fanucdatabackup_

    标题"FANUC-30iB-All-in-one-Data-Procedure_30ib_fanuc_fanucdatabackup_"所指的,是针对FANUC 30iB型号数控系统的全面数据备份流程。FANUC是全球领先的数控系统制造商,其30iB系列是广泛应用在工业制造领域的高端...

    psp.rar_The Procedure_临床

    "Psp.rar_The Procedure_临床" 文件包涉及的正是一个重要的随机化方法——Pocock-Simon Procedure(波科克-西蒙程序),它是临床试验设计中的一个重要工具。 Pocock-Simon Procedure 是由统计学家S. G. Pocock和M. ...

    All_Procedure_NO_Modify_3__PROC_BOM_PRICE_REFRESH.sql

    标题 "All_Procedure_NO_Modify_3__PROC_BOM_PRICE_REFRESH.sql" 暗示我们正在处理一个SQL脚本文件,可能是一个存储过程或者数据库维护脚本,用于更新BOM(Bill of Materials)价格信息。BOM是产品结构的详细清单,...

    ecc.zip_The Procedure_ecc java

    标题中的“ecc.zip_The Procedure_ecc java”表明这是一个与椭圆曲线密码学(Elliptic Curve Cryptography, ECC)相关的程序,可能是用Java语言编写的。ECC是一种先进的加密技术,它在确保数据安全方面提供了高效且...

    dcpcrypt_decrpt_TDCP_TheProcedure_

    procedure TDCP_blockcipher.Init - Use this proc to initialize the cipher withthe key data. Size is the size of the key data you are supplying in BITS.IVector is a pointer to the initialization vector ...

    cyk_procedure_STS35_LCD12864stc15w程序_

    标题中的"cyk_procedure_STS35_LCD12864stc15w程序"指的是一项使用STC15W系列单片机来控制STS35温度传感器,并将采集到的数据在LCD12864显示屏上显示的工程实践。这个程序涉及到了嵌入式系统开发、传感器数据处理和...

    藏经阁-HBase_Procedure_V2介绍.pdf

    它使用 WAL(Write-Ahead Log)来记录 Procedure 的执行信息,并在启动时将所有 WAL 都 replay 一遍来恢复数据。ProcedureStore 还维护了一个 Tracker 来跟踪活跃的 Procedure。 Procedure Lock 是一个锁机制,用于...

    vm.zip_The Procedure_visible watermarking_vm

    this is algorithm to do visible watermarking in this the step by step procedure is explained cleary to do visible watermarking in matlab

    ISTA_Procedure_2A_08-08.pdf

    Packaged-Products 150 lb (68 kg) or ...• The standard units chosen shall be used consistently throughout the procedure. • Units are converted to two significant figures and • Not exact equivalents

    EMC程序.rar_The Procedure_cylindrical_emc

    The Elliott’s procedure for the design of planar waveguide arrays of longitudinal slots has been extended to the cylindrical conformal case.

    lightweight_remote_procedure_call.zip_remote

    《轻量级远程过程调用(Lightweight Remote Procedure Call)详解》 在计算机科学领域,分布式系统中的通信机制是至关重要的。其中,轻量级远程过程调用(Lightweight Remote Procedure Call, LRPC)是一种被广泛...

    IHS-with-the-Wavelet-based-edge-extraction-proced_The Procedure_

    IHS with the Wavelet based edge extraction procedure

    Test_FastReportPrint4万能fr3报表查看器

    Test_FastReportPrint4万能fr3报表查看器 自设计中支持按文本格式查看fr3报表, 前提是报表中最好不要有图片,否则打开会无响应或反应很慢 测试fr3文件2M左右反应很慢 procedure TFrm_BarCode.FallBitBtn6Click...

    procedure-control1.zip_amplifier verilog_procedure vhdl_程控放大_程控放

    本压缩包“procedure-control1.zip”包含了使用Verilog语言编写的程控放大器(Programmable Amplifier)的设计实例,特别适合初学者学习和实践。 首先,让我们了解一下程控放大器的概念。程控放大器是一种可以通过...

Global site tag (gtag.js) - Google Analytics