求SQL语句一条.....(在线等)
数据库格式如下:
IDtitle(varchar 100)
1中共中央
22004-8-5
3中国人民
42005-9-8
52005-8-5
要求:显示数据库title小于2005-8-6(title不包括非日期型)
[解决办法]
create table T(ID int, title varchar(100) )insert into t select 1, '中共中央 'insert into t select 2, '2004-8-5'insert into t select 3, '中国人民'insert into t select 4, '2005-9-8'insert into t select 5, '2005-8-5'--要求:显示数据库title小于2005-8-6(title不包括非日期型) select *from twhere isdate(title)=1 and title<'2005-08-06'drop table T
[解决办法]
select * from
(select * from [table] where isdate(title)=1)aa
where datediff(day,title,'2005-8-6')>0
[解决办法]
select *
from t
where isdate(title)=1 and title<'2005-08-06'
这个不错,,,
[解决办法]
create table Layto(ID int, title varchar(100) )
insert into Layto select 1, '中共中央 '
insert into Layto select 2, '2004-8-5'
insert into Layto select 3, '中国人民'
insert into Layto select 4, '2005-9-8'
insert into Layto select 5, '2005-8-5'
select * from Layto
select * from Layto where isdate(title) = 1 and title<'2005-8-6'
-------------------------
ID title
22004-8-5
52005-8-5
[解决办法]
数据库格式如下:
ID title(varchar 100)
1 中共中央
2 2004-8-5
3 中国人民
4 2005-9-8
5 2005-8-5
要求:显示数据库title小于2005-8-6(title不包括非日期型)
----------------------
select * from tb where isdate(title) = 1 and cast(title as date) < '2005-08-06'