sql 语句
select count(*) times from bt_valid_log where convert(varchar(10),times,121) between '2011-05-05' and '2011-08-08'我想在这个语句上加一个条件 room=‘机房’这样的 该咋家呢?
select count(*) times from bt_valid_log where room=‘机房’and convert(varchar(10),times,121) between '2011-05-05' and '2011-08-08'不正确。谢谢!
[解决办法]
select count(*) times from bt_valid_log where room=‘机房’and ( convert(varchar(10),times,121) between '2011-05-05' and '2011-08-08')这样试试呢
或者换成>= <=
[解决办法]
count(*) times
与
convert(varchar(10),times,121)
一个别名,一个表字段,同名了,把count(*)的别名用其他的试试
[解决办法]
select count(*) times from bt_valid_log where room='机房' and convert(varchar(10),times,121) between '2011-05-05' and '2011-08-08';
[解决办法]
你用我9L那代码去查, 报的错误贴出来看下~~
[解决办法]
数据库此表 脚本贴出来看看~~~~
[解决办法]
按照你写convert(varchar(10),times,121)判断你数据库times 是datetime类型吧,就使用下面的吧
select count(*) times from bt_valid_log where room='机房' and times between "2011-05-05 00:00:00" and "2011-08-20 23:59:59";