SQL语句,请各位大大帮忙,小弟在线等!急........

chmz 2003-11-27 10:30:53
在表中有这样一些字段:
ssn,wo,fail_time,fail_station,id

现在的问题是怎样用SQL语句把fail_time为:01/01/00 00:00:00的数据选出来?
...全文
37 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
leeboyan 2003-11-27
  • 打赏
  • 举报
回复
如果fail_time字段设置默认值为getdate()
1.先在查询分析器里执行:
select * from table where (fail_time>='01/01/00 00:00:00' and fail_time<='01/01/00 00:00:00')
查询结果为例:fail_time为01/01/00 00:00:00.125
2.再执行select * from table where (fail_time='01/01/00 00:00:00.125')即可
gmlxf 2003-11-27
  • 打赏
  • 举报
回复
如果不是datetime类型,能不能用 :order by fail_time or group by fail_time?
-------------
group by可以
但是order by就不准确了

你建立字段的时候,你的字段fail_time定义datetime为好些,统计排序都方便。
chmz 2003-11-27
  • 打赏
  • 举报
回复
如果不是datetime类型,能不能用 :order by fail_time or group by fail_time?

erigido 2003-11-27
  • 打赏
  • 举报
回复
select * from yourTable where fail_time='01/01/00 00:00:00'
lvltt 2003-11-27
  • 打赏
  • 举报
回复
select * from table where fail_time = Convert(DateTime,'01/01/00 00:00:00')
khyhli 2003-11-27
  • 打赏
  • 举报
回复
select * from yourtable where convert(varchar(8),fail_time,112)='20000101'
gmlxf 2003-11-27
  • 打赏
  • 举报
回复
select * from yourTable where fail_time='01/01/00 00:00:00'
klan 2003-11-27
  • 打赏
  • 举报
回复
如果你的fail_time不是datetime类型的
select * from yourTable where fail_time='01/01/00 00:00:00'

否则
select * from yourTable where fail_time='2000-01-01 00:00:00'

34,874

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧