读书人

一条SQL语句

发布时间: 2012-04-19 14:36:43 作者: rapoo

求助一条SQL语句
select count(*) as countno from tgrht where (Fxb=1) and (TZZ_ID=1) and (fhtzzrq < '2007-09-12 ') 为什么出错,报类型不匹配错误。应该是日期那里,但是用to_date却说没有这个函数,有没别的办法?

Fxb和TZZ_ID 分别是数值型 fhtzzrq为日期型字段

高手帮帮忙

[解决办法]
select count(*) as countno from tgrht where (Fxb=1) and (TZZ_ID=1) and (fhtzzrq < '2007-09-12 ') 为什么出错,报类型不匹配错误。应该是日期那里,但是用to_date却说没有这个函数,有没别的办法?

Fxb和TZZ_ID 分别是数值型 fhtzzrq为日期型字段

高手帮帮忙
----------------
时间可以这样比较呀!
另外,SQL里用cast( '2007-09-12 ' as datetime) 或convert(datetime, '2007-09-12 ',120)可以转化时间
[解决办法]
可以比
SELECT * FROM sysobjects WHERE crdate < '2007/10/1 '
/*(2680 row(s) affected)*/
[解决办法]
select count(*) as countno from tgrht where (Fxb=1) and (TZZ_ID=1)
and (fhtzzrq < '2007-09-12 ')
日期应该没错
是前面两个错了吧

试试
select count(*) as countno from tgrht where (Fxb=1) and (TZZ_ID=1)

select count(*) as countno from tgrht where (fhtzzrq < '2007-09-12 ')
就知道了
[解决办法]
这么怪的,什么数据库

读书人网 >SQL Server

热点推荐