select * from tablename a
where code=(select min(code) from tablename where style=a.style)

解决方案 »

  1.   

    select a.* from tableName a,
    (select min(code) as code from tableName group by style) b
    where a.code=b.code
      

  2.   

    SELECT * FROM table WHERE (LEFT(CAST(style AS nvarchar), 3) = cast(code as nvarchar)
      

  3.   

    select * from table
    where code in (select min(code) from test2 group by style)
      

  4.   

    select * from tablename as A
    right join
    (select min(code) from tablename group by style) as B
    on A.code = B.code
      

  5.   

    select * from tablename where code in('111','113','114','117')
      

  6.   

    select min(code),max(name),style 
    group by style