国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當(dāng)前位置: 首頁(yè) - 科技 - 知識(shí)百科 - 正文

頁(yè)面PV按照年月日小時(shí)統(tǒng)計(jì)的存儲(chǔ)過程

來源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-09 16:16:17
文檔

頁(yè)面PV按照年月日小時(shí)統(tǒng)計(jì)的存儲(chǔ)過程

頁(yè)面PV按照年月日小時(shí)統(tǒng)計(jì)的存儲(chǔ)過程:需求:需要做一個(gè)統(tǒng)計(jì) 網(wǎng)站是這樣的:網(wǎng)站上有 視頻頻道、圖片頻道、新聞?lì)l道等 需要做一個(gè)統(tǒng)計(jì),能夠統(tǒng)計(jì)這幾個(gè)頻道 中每個(gè)資源 某個(gè)小時(shí)、 某天、某周、某月、某年、總的 訪問的次數(shù) 從上述需求看,只要統(tǒng)計(jì)每個(gè)資源,一天24 個(gè)小時(shí)的訪問量 然后分類匯總就
推薦度:
導(dǎo)讀頁(yè)面PV按照年月日小時(shí)統(tǒng)計(jì)的存儲(chǔ)過程:需求:需要做一個(gè)統(tǒng)計(jì) 網(wǎng)站是這樣的:網(wǎng)站上有 視頻頻道、圖片頻道、新聞?lì)l道等 需要做一個(gè)統(tǒng)計(jì),能夠統(tǒng)計(jì)這幾個(gè)頻道 中每個(gè)資源 某個(gè)小時(shí)、 某天、某周、某月、某年、總的 訪問的次數(shù) 從上述需求看,只要統(tǒng)計(jì)每個(gè)資源,一天24 個(gè)小時(shí)的訪問量 然后分類匯總就

需求:需要做一個(gè)統(tǒng)計(jì) 網(wǎng)站是這樣的:網(wǎng)站上有 視頻頻道、圖片頻道、新聞?lì)l道等 需要做一個(gè)統(tǒng)計(jì),能夠統(tǒng)計(jì)這幾個(gè)頻道 中每個(gè)資源 某個(gè)小時(shí)、 某天、某周、某月、某年、總的 訪問的次數(shù) 從上述需求看,只要統(tǒng)計(jì)每個(gè)資源,一天24 個(gè)小時(shí)的訪問量 然后分類匯總就

需求:需要做一個(gè)統(tǒng)計(jì)
網(wǎng)站是這樣的:網(wǎng)站上有 視頻頻道、圖片頻道、新聞?lì)l道 等

需要做一個(gè)統(tǒng)計(jì),能夠統(tǒng)計(jì)這幾個(gè)頻道 中每個(gè)資源 某個(gè)小時(shí)、 某天、某周、某月、某年、總的 訪問的次數(shù)

從上述需求看,只要統(tǒng)計(jì)每個(gè)資源,一天24 個(gè)小時(shí)的訪問量 然后分類匯總就可以 算出 某天、某周、某月、某年、總的 范圍的次數(shù)

原理就是這樣。


表結(jié)構(gòu)如下:
[Channel] 頻道表
ID
Name //頻道名稱

[Video] 視頻表
ID
...

[Photo] 圖庫(kù)表
ID
...

[News] 新聞表
ID
...


存儲(chǔ)過程用了下面的兩張表詳細(xì)的寫下:

[PV] 表
[ID] [int] IDENTITY(1,1) NOT NULL, [ChannelID] [int] NOT NULL,//頻道ID [SourceID] [int] NOT NULL,//源ID [Times] [int] NOT NULL,//次數(shù) [Y] [smallint] NULL,//年 如 2000 [M] [tinyint] NULL,//月 如 12 [W] [tinyint] NULL,//周 如 50 [D] [tinyint] NULL,//日 如 21 [H] [tinyint] NULL//小時(shí) 如 16


[PVS] 匯總結(jié)果表 [ID] [int] IDENTITY(1,1) NOT NULL, [ChannelID] [int] NOT NULL,//頻道ID [SourceID] [int] NOT NULL,//源ID [HourRate] [float] NULL,//當(dāng)前小時(shí)與上個(gè)小時(shí)相比上升的速率 [HourTimes] [int] NULL,//當(dāng)前小時(shí)訪問的次數(shù) [DayRate] [float] NULL,//今天與昨天相比上升的速率 [DayTimes] [int] NULL,//今天訪問的次數(shù) [WeekRate] [float] NULL,//當(dāng)周與上周相比上升的速率 [WeekTimes] [int] NULL,//當(dāng)周訪問的次數(shù) [MonthRate] [float] NULL,//當(dāng)月與上月相比上升的速率 [MonthTimes] [int] NULL,//當(dāng)周訪問的次數(shù) [YearRate] [float] NULL,//今年與上一年相比上升的速率 [YearTimes] [int] NULL,//今年訪問的次數(shù) [Total] [int] NULL//訪問的總次數(shù)






<無> $velocityCount-->
-- =============================================
-- Author:	
-- Create date: 
-- Description:	
-- =============================================
CREATE proc [dbo].[procCountPV](
@ChannelID nvarchar(50),
@SourceID int
)
as
begin
	declare @TEMID int; --臨時(shí)ID
	declare @Now datetime;
	set @Now = GETDATE();
	
	declare @Y smallint;--年
	declare @M tinyint;--月
	declare @W tinyint;--周
	declare @D tinyint;--日
	declare @H tinyint;--小時(shí)
	
	set @Y = DATEPART(YY,@Now);
	set @M = DATEPART(MM,@Now);
	set @W = DATEPART(WW,@Now);
	set @D = DATEPART(DD,@Now);
	set @H = DATEPART(HH,@Now);
	
	
	select @TEMID = [ID] from [PV] where [ChannelID] = @ChannelID and [SourceID]=@SourceID and [Y] = @Y and [M]=@M and [D]=@D and [H] = @H;
	
	if @TEMID is null
	Insert into [PV]([ChannelID],[SourceID],[Times],[Y],[M],[W],[D],[H]) values(@ChannelID ,@SourceID,1,@Y,@M,@W,@D,@H);
	else
	Update [PV] set [Times] = [Times]+1 where [ID]= @TEMID;	
	
	/*計(jì)算現(xiàn)在*/
	Declare @NowHourTimes int;
	Declare @NowDayTimes int;
	Declare @NowWeekTimes int;
	Declare @NowMonthTimes int;
	Declare @NowYearTimes int;
	
	--Y M D H
	select @NowHourTimes = SUM([Times]) from [PV] where ChannelID = @ChannelID and SourceID = @SourceID and [Y] = @Y and [M]=@M and [D]=@D and [H] = @H;	
	
	--Y M D
	select @NowDayTimes = SUM([Times]) from [PV] where ChannelID = @ChannelID and SourceID = @SourceID and [Y] = @Y and [M]=@M and [D]=@D;	
	
	--Y W
	select @NowWeekTimes = SUM([Times]) from [PV] where ChannelID = @ChannelID and SourceID = @SourceID and [Y] = @Y and [W]=@W;
	
	--Y M
	select @NowMonthTimes = SUM([Times]) from [PV] where ChannelID = @ChannelID and SourceID = @SourceID and [Y] = @Y and [M]=@M;
	
	--Y
	select @NowYearTimes = SUM([Times]) from [PV] where ChannelID = @ChannelID and SourceID = @SourceID and [Y] = @Y;
	
	
	if @NowHourTimes is null
	set @NowHourTimes = 0;
	
	if @NowDayTimes is null
	set @NowDayTimes = 0;

	if @NowWeekTimes is null
	set @NowWeekTimes = 0;

	if @NowMonthTimes is null
	set @NowMonthTimes = 0;

	if @NowYearTimes is null
	set @NowYearTimes = 0;
	
	
	
	
	/*計(jì)算之前*/
	Declare @PreHourTimes int;
	Declare @PreDayTimes int;
	Declare @PreWeekTimes int;
	Declare @PreMonthTimes int;
	Declare @PreYearTimes int;
	
	
	
	--Y M D H
	Declare @PreHourDateTime datetime;
	set @PreHourDateTime = DATEADD(HH,-1,@Now);
	
	select @PreHourTimes = SUM([Times]) from [PV] where ChannelID = @ChannelID and SourceID = @SourceID and [Y] = DATEPART(YY,@PreHourDateTime) and [M]=DATEPART(MM,@PreHourDateTime) and [D]=DATEPART(DD,@PreHourDateTime) and [H] = DATEPART(HH,@PreHourDateTime);	
	
	--Y M D
	Declare @PreDayDateTime datetime;
	set @PreDayDateTime = DATEADD(DD,-1,@Now);
	
	select @PreDayTimes = SUM([Times]) from [PV] where ChannelID = @ChannelID and SourceID = @SourceID and [Y] = DATEPART(YY,@PreDayDateTime) and [M]=DATEPART(MM,@PreDayDateTime) and [D]=DATEPART(DD,@PreDayDateTime);	
	
	--Y W
	Declare @PreWeekDateTime datetime;
	set @PreWeekDateTime = DATEADD(WW,-1,@Now);

	select @PreWeekTimes = SUM([Times]) from [PV] where ChannelID = @ChannelID and SourceID = @SourceID and [Y] = DATEPART(YY,@PreWeekDateTime) and [W]= DATEPART(WW,@PreWeekDateTime);
	
	--Y M
	Declare @PreMonthDateTime datetime;
	set @PreMonthDateTime = DATEADD(MM,-1,@Now);
	select @PreMonthTimes = SUM([Times]) from [PV] where ChannelID = @ChannelID and SourceID = @SourceID and [Y] = DATEPART(YY,@PreMonthDateTime) and [M]= DATEPART(MM,@PreMonthDateTime);
	
	--Y
	select @PreYearTimes = SUM([Times]) from [PV] where ChannelID = @ChannelID and SourceID = @SourceID and [Y] = @Y - 1;
	
	
	if @PreHourTimes is null
	set @PreHourTimes = 0;
	
	if @PreDayTimes is null
	set @PreDayTimes = 0;

	if @PreWeekTimes is null
	set @PreWeekTimes = 0;

	if @PreMonthTimes is null
	set @PreMonthTimes = 0;

	if @PreYearTimes is null
	set @PreYearTimes = 0;

	
	declare @HourRate float;
	declare @DayRate float;
	declare @WeekRate float;
	declare @MonthRate float;
	declare @YearRate float;
	
	set @HourRate = 0;
	set @DayRate = 0;
	set @WeekRate = 0;
	set @MonthRate = 0;
	set @YearRate = 0;
	
	if @PreHourTimes > 0 
	set @HourRate = ( @NowHourTimes - @PreHourTimes )/ (@PreHourTimes+0.0);	
	
	if @PreDayTimes > 0 
	set @DayRate = ( @NowDayTimes - @PreDayTimes )/ (@PreDayTimes+0.0);
	
	if @PreWeekTimes > 0 
	set @WeekRate = ( @NowWeekTimes - @PreWeekTimes )/ (@PreWeekTimes+0.0);
	
	if @PreMonthTimes > 0 
	set @MonthRate = ( @NowMonthTimes - @PreMonthTimes )/ (@PreMonthTimes+0.0);
	
	if @PreYearTimes > 0 
	set @YearRate = ( @NowYearTimes - @PreYearTimes )/ (@PreYearTimes+0.0);
	


	
	
	/*計(jì)算總量*/
	declare @Total int;
	select @Total = SUM([Times]) From [PV] where ChannelID = @ChannelID and SourceID = @SourceID;
	if @Total is null
	set @Total = 0;	
	
	declare @TempID int;
	set @TempID = null;
	
	/*操作CountSummary*/	
	Select @TempID = ID from [PVS]	where ChannelID = @ChannelID and SourceID = @SourceID;
	if @TempID is null 	
	Insert into [PVS]([ChannelID],[SourceID],[HourRate],[HourTimes],[DayRate],[DayTimes],[WeekRate],[WeekTimes],[MonthRate],[MonthTimes],[YearRate],[YearTimes],[Total]) 
	Values(@ChannelID,@SourceID,@HourRate,@NowHourTimes,@DayRate,@NowDayTimes,@WeekRate,@NowWeekTimes,@MonthRate,@NowMonthTimes,@YearRate,@NowYearTimes,@Total);
	else	
	Update [PVS] set [HourRate]=@HourRate,[HourTimes]=@NowHourTimes,[DayRate]=@DayRate,[DayTimes]=@NowDayTimes,[WeekRate]=@WeekRate,[WeekTimes]=@NowWeekTimes,[MonthRate]=@MonthRate,[MonthTimes]=@NowMonthTimes,[YearRate]=@YearRate,[YearTimes]=@NowYearTimes,[Total]=@Total where ID = @TempID;	
end

GO

CREATE TABLE [dbo].[PV](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[ChannelID] [int] NOT NULL,
	[SourceID] [int] NOT NULL,
	[Times] [int] NOT NULL,
	[Y] [smallint] NULL,
	[M] [tinyint] NULL,
	[W] [tinyint] NULL,
	[D] [tinyint] NULL,
	[H] [tinyint] NULL,
 CONSTRAINT [PK_PV] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[PV] ADD CONSTRAINT [DF_PV_Times] DEFAULT ((0)) FOR [Times]
GO

ALTER TABLE [dbo].[PV] ADD CONSTRAINT [DF_PV_Y] DEFAULT ((2000)) FOR [Y]
GO

ALTER TABLE [dbo].[PV] ADD CONSTRAINT [DF_PV_M] DEFAULT ((1)) FOR [M]
GO

ALTER TABLE [dbo].[PV] ADD CONSTRAINT [DF_PV_W] DEFAULT ((1)) FOR [W]
GO

ALTER TABLE [dbo].[PV] ADD CONSTRAINT [DF_PV_D] DEFAULT ((1)) FOR [D]
GO

ALTER TABLE [dbo].[PV] ADD CONSTRAINT [DF_PV_H] DEFAULT ((0)) FOR [H]
GO

CREATE TABLE [dbo].[PVS](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[ChannelID] [int] NOT NULL,
	[SourceID] [int] NOT NULL,
	[HourRate] [float] NULL,
	[HourTimes] [int] NULL,
	[DayRate] [float] NULL,
	[DayTimes] [int] NULL,
	[WeekRate] [float] NULL,
	[WeekTimes] [int] NULL,
	[MonthRate] [float] NULL,
	[MonthTimes] [int] NULL,
	[YearRate] [float] NULL,
	[YearTimes] [int] NULL,
	[Total] [int] NULL,
 CONSTRAINT [PK_PVS] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

頁(yè)面PV按照年月日小時(shí)統(tǒng)計(jì)的存儲(chǔ)過程

頁(yè)面PV按照年月日小時(shí)統(tǒng)計(jì)的存儲(chǔ)過程:需求:需要做一個(gè)統(tǒng)計(jì) 網(wǎng)站是這樣的:網(wǎng)站上有 視頻頻道、圖片頻道、新聞?lì)l道等 需要做一個(gè)統(tǒng)計(jì),能夠統(tǒng)計(jì)這幾個(gè)頻道 中每個(gè)資源 某個(gè)小時(shí)、 某天、某周、某月、某年、總的 訪問的次數(shù) 從上述需求看,只要統(tǒng)計(jì)每個(gè)資源,一天24 個(gè)小時(shí)的訪問量 然后分類匯總就
推薦度:
標(biāo)簽: 一個(gè) 過程 頁(yè)面
  • 熱門焦點(diǎn)

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 伊人精品成人久久综合欧美 | 国产在线视频资源 | 欧美日韩成人在线 | 亚洲国产精品日韩高清秒播 | 国内精品视频在线观看 | 国产精品亚洲四区在线观看 | 91在线 一区 二区三区 | 亚洲一区免费视频 | 日韩欧美国产精品第一页不卡 | 亚洲第一区视频 | 亚洲欧美综合区自拍另类 | 91成人午夜性a一级毛片 | 黄毛片免费 | 热久久国产欧美一区二区精品 | 国产在线视频在线观看 | 我被公睡做舒服爽中文字幕 | 日韩精品一区在线 | 亚洲 欧洲 另类 综合 自拍 | 亚洲另类第一页 | 久久婷婷色一区二区三区 | 91久久精品国产91久久性色也 | 国产123区在线视频观看 | 国产va免费精品 | 亚欧成人毛片一区二区三区四区 | 欧美亚洲综合一区 | 全黄毛片 | 国产精品久久久久久久久 | 精品日韩在线 | 国产在线高清不卡免费播放 | 国语对白91 | 国产一级淫片a免费播放口 国产一级特黄a大片99 | 真实的国产乱xxxx在线 | 激情另类国内一区二区视频 | 亚洲一区二区免费视频 | 97久久精品午夜一区二区 | 国产高清美女一级a毛片久久 | 亚洲欧美日韩第一页 | 国产视频在 | 国产有码视频 | 成人特黄午夜性a一级毛片 成人国产一区二区三区精品 | 亚洲 欧美 日韩在线 |