select * from table A where 单位 in (select max(单位) from table where 课号=A.课号)

解决方案 »

  1.   

    Select 课号,主副消备,品名,规格名,max(单位),sum(上月初),sum(本月入)
    group by 课号,主副消备,品名,规格名
      

  2.   

    Select 课号,主副消备,品名,规格名,max(单位),sum(上月初),sum(本月入)
    from 表
    group by 课号,主副消备,品名,规格名
      

  3.   

    select * from
    (
    select 课号,主副消备,品名,规格名,sum(上月初) as 上月初,sum(本月入) as 本月入
    from t
    group by 课号, 主副消备, 品名,规格名
    )a,
    (select 课号,主副消备,品名,规格名,单位 
    from t 
    where 单位<>'' and 单位 is not null
    ) b
    where a.课号=b.课号 
    and a.主副消备= b.主副消备
    and a.品名=b.品名
    and a.规格名=b.规格名