select count(a) AA from table group by a order by AA,其中AA是列的别名

解决方案 »

  1.   

    select aa.a,aa.b from (select a,to_number(b) b from table group by a,to_number(b) order by to_number(b) desc) aa where rownum<=n;
      

  2.   

    不太明白你的结果到底要什么?
    一下仅供参考:
    select * from tbl group by a,b order by a,b desc
      

  3.   

    我的意思是这样的:
     lukou varchar(10),qita varchar(10);'A','XXX'
    'A','XX'
    'A','XXHJ'
    'A','XXXLL'
    'A','XXXIIOO'
    'B','FDSA'
    'B','FDSAFD',
    'C','FDSADFSAF',
    'C','GFSG',
    'C','FDASASF'
    'C','FDSAFSA',其中A出现5次,B出现2次,C出现4次,
    怎么样得到前两名:
      A     5
      B     4
    不知道我说明白了没有
      

  4.   

    select a,count(a) a1 from table where rownum<=2 group by a order by a
      

  5.   

    select a,count(a) a1 from table where rownum<=2 group by a order by a1
      

  6.   

    select a,count(a) a1 from table where rownum<=2 group by a order by a1 desc
      

  7.   

    select * from
    (select lukou,count(*) cnt from yourtable group by lukou order by cnt desc
    ) t
    where rownum <= 2
      

  8.   

    select lukou,sl 
    from (select lukou,count(*) sl from test1 group by lukou order by sl desc) t 
    where rownum<=2