您的位置:首页编程相关 → 正文

SQL技巧:创建用来按小时报告的查询

文章来源:本站整理收集  文章录入:陈洁绫  【放大字体 缩小字体】


要创建一个可以每个小时报告的查询,首先要创建一个表格。该表格一列记录日期,而没有时间信息;另一列记录钟点。下面的表格有一列记录了不同的处理类型。例如,我们可以按小时找出处理类型的总数。

create table test (starttime datetime not null default current_timestamp, startdate datetime not null default convert(datetime, convert(char(10),current_timestamp, 110)), starthour int not null default datepart(hh,current_timestamp), trantype int not null constraint ck_trantype check ( trantype in ( 1, -- insert 2, -- update 3, -- delete ) default 1 ) go

如果在这里没找到您所需要的资料,请点击这里到论坛寻求帮助,我们将尽量帮您解答。
打印本文  返回顶部  加入收藏  关闭窗口