房天下 > 房天下问答 > 业主生活 > 其他
  • 使用sql将一列时间分为上下午两列

    写一条sql语句将12:00:00之前分为一列AM,12:00:00之后为pmtime2010-06-06 8:00:002010-06-06 12:00:002010-06-07 8:00:002010-06-07 12:00:002010-06-08 7:00:002010-06-08 13:00:00查询以后为am pm2010-06-06 8:00:00 2010-06-06 12:00:002010-06-07 8:00:00 2010-06-07 12:00:00 2010-06-08 7:00:00 2010-06-08 13:00:00

    提问者:sinzd

    发布于2011-01-20

共1个回答
  • 永盛通讯 丨Lv 3
    使用下列语句,我测试过,没有问题的,time字段要加引号的select 'time', case when 'time' >= cast(left('time',10)+' 12:00:00' as datetime) then null else 'time'end as am,case when 'time' < cast(left('time',10)+' 12:00:00' as datetime) then null else 'time'end as pm from 表
    +1 2011-01-21 举报
热门人气推荐
免责声明:问答内容均来源于互联网用户,房天下对其内容不负责任,如有版权或其他问题可以联系房天下进行删除。