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

文章作者 100test 发表时间 2007:03:10 18:22:06
来源 100Test.Com百考试题网


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

3, -- 0delete

)

default 1

)

go

相关文章


线性表的定义特征与运算
SQL技巧:创建用来按小时报告的查询
ASP.NET中如何防范SQL注入式攻击
使用动态SQL克隆数据库对象
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛