相同 table 中的最小和最大日期时间

Min and max datetime in same table

select WorkDay,
MIN(WorkDay) as dayOn,
MAX(WorkDay) as DayOff
from Records
where YEAR(WorkDay)=2014 and MONTH(WorkDay) =10 and EnNo=10
group by WorkDay

查询显示如下结果

WorkDays                          DayOn                     Dayoff
2014-10-04 08:13:00.000     2014-10-04 08:13:00.000    2014-10-04 08:13:00.000
2014-10-04 17:19:00.000     2014-10-04 17:19:00.000    2014-10-04 17:19:00.000

但我需要类似下面的数据

WorkDays                       DayOn                     Dayoff Oct
2014-10-04            2014-10-04 08:13:00.000       2014-10-04 17:19:00.000

请有人解决这个问题 谢谢,

select WorkDay = cast(floor(cast(WorkDay as float)) as datetime),
MIN(WorkDay) as dayOn,
MAX(WorkDay) as DayOff
from Records
where YEAR(WorkDay)=2014 and MONTH(WorkDay) =10 and EnNo=10
group by  cast(floor(cast(WorkDay as float)) as datetime)

您也可以尝试以下方法

select CONVERT( date, WorkDay),
MIN(WorkDay) as dayOn,
MAX(WorkDay) as DayOff
from Records
where YEAR(WorkDay)=2014 and MONTH(WorkDay) =10 and EnNo=10
group by CONVERT( date,  WorkDay)