select max(b) from table where a='1'

解决方案 »

  1.   

    select top 1 * from table where a='1' order by b desc
      

  2.   

    但是显示在web页面上时这条记录前面会有若干空行,就是被滤到的一些记录,请问如何解决
      

  3.   

    select * from table1
    where b in(select top 1 b from table1 where a='1' order by b desc)
      

  4.   

    select * from table1
    where b in(select top 1 b from table1 where a='1' order by b desc)
    and a='1'
      

  5.   

    insert into #aa
    select * from talbe1 where a='1'
    select max(b) from #aa
      

  6.   

    select * from table1
    where b = (select max(b) from table1 where a='1') and a='1'
      

  7.   

    支持 yoki(小马哥) 的回答,我試過了
      

  8.   

    select * from 表名 where B IN (select max(B) from 表名 where a=1)这个也行,yoki(小马哥)的:
    select * from 表名
    where B in(select top 1 B from 表名 where A='1' order by B desc)
    and A='1'
      

  9.   

    引用(共同进步)的回复
    select * from 表名 where B IN (select max(B) from 表名 where a=1)这个应该是最简单的,而且目的也能达到。但是如果数据量大的话,查询的速度可能会慢点。
      

  10.   

    TO yyy431706(共同进步)
    你的查詢語句後面還是要加上and a='1',否則查到的會a=其它的東東
    試驗的結果:)