SQL 我现在有表A和B,要选择出 A表中nPri 小于 通过与B表关联过来的A的最小的nPri ,A与B的关联规则是 A.ID = B.nGrop and B.sTatus <> 100

解决方案 »

  1.   


    select *
    from A INNER JOIN B ON A.ID = B.nGrop 
    where and B.sTatus <> 100 
          and A.nPri<(select MIX(B.nPri)
                     from A INNER JOIN B ON A.ID = B.nGrop 
                     where and B.sTatus <> 100)
      

  2.   


    declare @npri int
    select @npri = min(a.npri) from a,b where a.ID = b.nGrop and b.sTatus <> 100select * from a where npri < @npri
      

  3.   


    select a.* from a where nPri < (select min(nPri) from b where A.ID = B.nGrop and B.sTatus <> 100 )
      

  4.   

    <any
    select a.* from a where nPri<any(select nPri from b where A.ID = B.nGrop and B.sTatus <> 100 )
      

  5.   


    select * 
      from a 
     where nPri <  ( select min(nPri) 
                       from b where A.ID = B.nGrop 
                        and B.sTatus <> 100
                   )
      

  6.   


    select * 
      from a 
     where nPri <  ( select min(a.nPri) 
                       from a,b 
                      where A.ID = B.nGrop 
                        and B.sTatus <> 100
      

  7.   


    select * 
      from a 
     where nPri <  ( select min(a.nPri) 
                       from a,b 
                      where A.ID = B.nGrop 
                        and B.sTatus <> 100
                    )