select 目前单据步骤,
       处于该步单据总数=count(*),
       小等于该步单据总数=(select count(*) from t where 目前单据步骤<a.目前单据步骤),
       大于该步单据总数=(select count(*) from t where 目前单据步骤>a.目前单据步骤),
       该步紧急单据总数=sum(紧急程度)
from t a
group by 目前单据步骤

解决方案 »

  1.   

    select 目前单据步骤,
           处于该步单据总数=count(*),
           小等于该步单据总数=(select count(*) from t where 目前单据步骤<a.目前单据步骤),
           大于该步单据总数=(select count(*) from t where 目前单据步骤>a.目前单据步骤),
           该步紧急单据总数=sum(紧急程度)
    from t a
    group by 目前单据步骤
      

  2.   

    select 目前单据步骤,
           处于该步单据总数=count(*),
           小等于该步单据总数=(select count(*) from t where 目前单据步骤=<a.目前单据步骤),
           大于该步单据总数=(select count(*) from t where 目前单据步骤>a.目前单据步骤),
           该步紧急单据总数=sum(紧急程度)
    from t a
    group by 目前单据步骤