select distinct top 5 * from b order by bid desc

解决方案 »

  1.   

    select top 5 * from (select distinct * from 表b) tem order by bid desc??
      

  2.   

    select top 5 bid,(select [name] from 表a where aid=tem.aid) [name] from (select distinct * from 表b) tem order by bid desc
    ???
      

  3.   

    select top 5 *
    from (select distinct * from b) table
    order by bid desc
      

  4.   

    你只要查B表的数据?和A表没有关系吗?
    还有你指的不重复是B表所有字段不重复还是只针对aid字段不重复?
      

  5.   

    select b.bid,a.name from a,(select distinct top 5 * from b order by bid desc) b where a.aid=b.bid
      

  6.   


    select top 5 * from 表b  a 
    where bid in 
    (select max(bid) from 表b  where aid=a.aid  )
    order by aid asc
    ---
    bid      aid
    12 1
    10 2
    9 3??
      

  7.   

    select top 5 * from (select distinct * from b) as table
    order by bid desc
      

  8.   

    表B的aid对应表a中的id即要求满足 b.aid=a.id