开发者社区 问答 正文

如何合并 SQL Server 中的两行

如何合并 SQL Server 中的两行

展开
收起
贺贺_ 2019-12-02 22:25:48 430 分享 版权
1 条回答
写回答
取消 提交回答
  • 可以使用条件聚合:

    select date, max(case when cond = 1 then time end) as time_1,
           max(case when cond = 0 then time end) as time_0
    from t
    group by date
    order by date;
    
    2019-12-02 22:26:00
    赞同 展开评论
问答标签:
问答地址: