表结构如下
日期,上班,下班
20100506 08:01 17:00
20100506 07:41 17:20
20100506 07:51 16:00需要拉出这样的数据表,在旁边加上迟到或早退备注
如20100506 08:01 17:00 迟到上班>8:00迟到
下班<17:00 早退
日期,上班,下班
20100506 08:01 17:00
20100506 07:41 17:20
20100506 07:51 16:00需要拉出这样的数据表,在旁边加上迟到或早退备注
如20100506 08:01 17:00 迟到上班>8:00迟到
下班<17:00 早退
case when convert(varchar(5),下班,14)<'17:00' then '迟到+早退' else '迟到' end
when convert(varchar(5),下班,14)<'17:00' then '早退' end
from tb
,case when cast(下班 as varchar(5))<'17:00' then '早退' else '' end as re2
from tb
case when 下班<'17:00' then 下班+' 早退' esle 下班 end 下班
from tablea