建立一对相对动态视图,主要与当前时间有关.....分数不够再加.多请高手的指点

suziniren 2005-09-22 04:04:01
表T_AA 中有一字段是varchar的...值为 20050922001,20050922002,20050922003,20050923001,20050922002,20050922003

我现在想建立一个视图查询近十五天的记录我要怎么写啊???视图中只显示近十五天的记录

谢各位大侠指点...谢谢了
...全文
45 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
suziniren 2005-09-22
libin_ftsafe(子陌红尘)十分感谢你的帮助,谢谢!
回复
子陌红尘 2005-09-22
create table T_AA(col varchar(20))
insert into T_AA select '20050901001'
insert into T_AA select '20050906001'
insert into T_AA select '20050907001'
insert into T_AA select '20050908001'
insert into T_AA select '20050909001'
insert into T_AA select '20050912001'
insert into T_AA select '20050915001'
insert into T_AA select '20050901001'
insert into T_AA select '20050922001'
insert into T_AA select '20050922002'
insert into T_AA select '20050922003'
insert into T_AA select '20050923001'
insert into T_AA select '20050922002'
insert into T_AA select '20050922003'
go


create view v1 as
select
*
from
T_AA
where
datediff(dd,cast(left(col,8) as datetime),getdate())<15
go


select * from v1
/*
col
-----------
20050908001
20050909001
20050912001
20050915001
20050922001
20050922002
20050922003
20050923001
20050922002
20050922003
*/
回复
子陌红尘 2005-09-22
create view v1 as
select
*
from
T_AA
where
datediff(dd,cast(字段名 as datetime),getdate())<15
回复
相关推荐
发帖
应用实例
创建于2007-09-28

2.7w+

社区成员

MS-SQL Server 应用实例
申请成为版主
帖子事件
创建了帖子
2005-09-22 04:04
社区公告
暂无公告