将每个日期的多个相同日期行转换为单个

时间:2019-04-25 05:24:55

标签: sql-server

我的表格在一个日期中包含许多数据,我想在日期时间列中使用日期将这些行分组,并在单个行中显示

实际输出:

start time                 EndTime                   Downtimeid

-----------------------   ------------------         ----------------

2018-11-26 06:00:00.000 2018-11-26 08:00:00.000 1 2018-11-26 06:00:00.000 2018-11-26 08:06:00.000 1 2018-11-26 06:00:00.000 2018-11-26 ....... 2018-11-26 06:00:00.000 2018-11-26 06:00:00.000 2018-11-25 22:00:00.000 2018-11-25 22:00:00.000 2018-11-25 22:00:00.000 2018-11-25 22:00:00.000 2018-11-25 22:00:00.000 2018-11-25 14:00:00.000 2018-11-25 14:00:00.000 2018-11-25 14:00:00.000 预期输出:

2018-11-26 06:00:00.000,    2018-11-26 08:00:00.000    1 
2018-11-25 00:00:00.000

3 个答案:

答案 0 :(得分:1)

table.table-bordered>tbody>tr>td {
    border: 1px solid rgba(29, 150, 178, 1);
    white-space: nowrap;
    font-family: Verdana;
    font-size: 8pt;
    background-color: rgba(84, 83, 72, .1);
    color: black;
    padding: 0;
}

答案 1 :(得分:0)

如果您不想时间,可以使用

SELECT  CAST(start_time AS DATE) 
FROM   tablename
GROUP BY CAST(start_time AS DATE)

答案 2 :(得分:0)

enter image description here

select Start_Time
from ShowDate
Group by Start_Time
order by Start_Time desc