【问题标题】:Count maximum consecutive row out of total row for each day Ms-Sql计算每天 Ms-Sql 总行中的最大连续行
【发布时间】:2018-11-03 15:09:33
【问题描述】:

我想要每天和每一天的总行数想要连续的最大行数,其中条件 numb>2 和校准!=1 来自下图中的表格

并且期望的输出应该是

【问题讨论】:

    标签: sql sql-server tsql sql-server-2005


    【解决方案1】:

    我想你想要条件聚合:

    select todaydate, count(*) as totalrow,
           sum(case when (numb > 2 and calibration <> 1) then 1 else 0 end) as [max]
    from table t 
    group by todaydate;
    

    【讨论】:

    • 如果它是正确的,一定要接受这个答案,@priyankacharya
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-25
    • 1970-01-01
    • 1970-01-01
    • 2022-11-25
    • 1970-01-01
    相关资源
    最近更新 更多