table aa
a b c d e
1 2 3 9 0
5 7 6 8 1我想取e字段为0并且d字段最大中的b字段的值。  该再写sql语句呢?

解决方案 »

  1.   

    select b from aa where aa.d  = (select max(d) from aa where e = 0)
      

  2.   

    select  max(a1.b) A,(select a2.e
       from aa a2 
       where a2.e='0') B
    from aa a1
      

  3.   

    SELECT B FROM AA WHERE E=0 AND D=(SELECT MAX(D) FROM AA)
      

  4.   

    a1 a2 是表的别名 A B 是列的别名  不知道你要的是不是这个效果  不过你这种取值比较特殊我用内联视图做的
      

  5.   

    select b from aa where e='0' and d in(select max(d) from aa where e='0')
    这个是真确的  不过还是谢谢大家了!!