以下的表结构,需要自增一个字段
 theTime     自定义字段
 7:23
 9:23
 18:35
 21:15
5:42凡是对于时间大于或者等于 18:30 的时候,以0.2为起始数,自增字段以每半小时为单位递增 0.1,例如当theTime显示 18:07,那么 自增字段显示 (空)
theTime显示 18:35,那么 自增字段显示 0.2
theTime显示 19:01,那么 自增字段显示 0.3
theTime显示 19:55,那么 自增字段显示 0.4请问sql语句怎么写?

解决方案 »

  1.   

    theTime显示 18:35,那么 自增字段显示 0.2
    theTime显示 19:01,那么 自增字段显示 0.3
    --------------
    有半个小时了?
      

  2.   


    select DATEDIFF(MI,'18:00','19:55')/30*0.1+0.1
      

  3.   

    select case when thetime<'18:30' then null else datediff(minute,cast('18:30' as smalldatetime),cast(thetime as smalldatetime))/300+0.2