用top  和  order by  不知道行不行??

解决方案 »

  1.   

    select bookid from tablename group by bookid having count(*)=
    (select max(times) from 
    (select bookid,count(*) as times from tablename group by bookid) a)
      

  2.   

    select top 1 bookid,count(*) as times from tablename group by bookid order by times desc
      

  3.   

    -- 你这个是什么语法?有点看不懂
    select top bookid from tablename group by bookid order by count(1)
      

  4.   

    select top 1 bookid from tablename group by bookid order by count(1) desc
      

  5.   

    create table a(bookid varchar(10),bookname varchar(20))
    insert into a select '001','1111'
    union all select '002','2222'
    union all select '003','3333'
    union all select '001','1111'
    union all select '002','2222'
    union all select '001','1111'
    select top 1 bookid,count(bookid) from a group by bookid order by count(bookid) desc
    drop table a(所影响的行数为 6 行)bookid                 
    ---------- ----------- 
    001        3(所影响的行数为 1 行)
      

  6.   

    select top 1 count(*) from tablename group by bookid order by count(*) desc
      

  7.   

    as times`的用发是怎么样的?
      

  8.   

    order by后面可以用聚集函数吗?
      

  9.   

    就是把count(*) --(bookid借出的次數)賦一個字段名啊,
      

  10.   

    如果用的是group by ,order by后面就可以用聚集函数
      

  11.   

    如果用的是group by ,order by后面就可以用聚集函数,什么意思?有group by,后面的ordr by就可以用聚集函数了???????
      

  12.   

    select top 1 count(*) ,title 
    into :z,:name 
    from tablename 
    group by bookid
    order by count(*) desc