select * from table1 where substring(item,3,3) in (select substring(item) from table1)
and seq=(select max(seq) from table1)

解决方案 »

  1.   

    select identity(int,1,1) as id,* into #temp from table order by seqselect * from #temp where id in(
    select max(id) from #temp group by substring(item,3,3))
      

  2.   

    修改一下
    select * from table1 where substring(item,3,3) in (select substring(item,3,3) from table1)
    and seq=(select max(seq) from table1)
    没有测试过,试试刊
      

  3.   

    select * from tablename a
    where item=(select top 1 item from tablename b where substring(b.Item,3,3)=substring(a.Item,3,3)
    and Seq=(select max(Seq) from tablename where substring(Item,3,3)=substring(b.Item,3,3))
    )
      

  4.   

    select max(item),max(seq) from t1 group by substring(item,3,3)
      

  5.   

    错了,改;
    select max(item),max(seq) from t1 
    where seq in (select max(seq) from t1 group by substring(item,3,3))
    group by substring(item,3,3)