为了账号安全,请及时绑定邮箱和手机立即绑定

关于sql的时间问题

关于sql的时间问题

幕布斯7119047 2018-11-10 13:12:42
我有一张表有个字段,Id 自增列,InsertTime 时间,Speed 速率  我想通过速率计算两个时间,第一个是当速率为0的时间,第二是速率不为0的时间,select InsertTime from table where Speed='0.00'---时间1select InsertTime from table where Speed<>'0.00' ----时间2怎么把两个时间组合成一个表,一个表示开始时间,一个表示结束时间
查看完整描述

2 回答

?
桃花长相依

TA贡献1860条经验 获得超8个赞

你的一个记录,一个 id只有一个时间,怎么表示 开始 和结束

select id,'开始时间'=case when Speed='0.00' then InsertTime else '--' end,
'结束时间'=case when Speed <>'0.00' then InsertTime else '--' end from table


查看完整回答
反对 回复 2018-11-14
?
守着星空守着你

TA贡献1799条经验 获得超8个赞

select '开始时间',InsertTime from table where Speed='0.00'---时间1

union

select '结束时间',InsertTime from table where Speed<>'0.00' ----时间2


查看完整回答
反对 回复 2018-11-14
  • 2 回答
  • 0 关注
  • 566 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信