select a.*  --这里你可以指定任意的你要想显示的字段
from table1 a join(
select id=max(id)
from table1
group by 颜色,类型,单位
)b on a.id=b.id

解决方案 »

  1.   

    --测试--测试数据
    create table Table1(ID int identity(1,1),颜色 varchar(10),类型 varchar(10),单位 varchar(10),价格 decimal(10,1))
    insert table1 select '红色','大','个',1.5
    union  all    select '红色','大','对',1.6
    union  all    select '红色','小','个',1.6
    union  all    select '红色','大','个',1.7
    union  all    select '黄色','大','个',1.8
    union  all    select '黄色','大','个',2.8
    union  all    select '黄色','大','个',3.0
    go--查询
    select a.*
    from table1 a join(
    select id=max(id)
    from table1
    group by 颜色,类型,单位
    )b on a.id=b.id
    go--删除测试
    drop table table1/*--测试结果ID          颜色         类型         单位         价格           
    ----------- ---------- ---------- ---------- ------------ 
    2           红色         大          对          1.6
    3           红色         小          个          1.6
    4           红色         大          个          1.7
    7           黄色         大          个          3.0(所影响的行数为 4 行)
    --*/