请教 一个统计和排序问题

 所属目录:Java   |   类型:技术问答   |   时间:2007-05-21
 问题:

一个表a   字段b  
  字段b中的数据是任意的   假设是日期吧!  
   
  我现在想求   哪一天的记录最多     然后按每天记录多少排序   显示出来  
   
  新手   请指教

· 网友精彩回答:

发表者:hdhai9451

select   字段b,count(字段b)   from   表a  
  group     by   字段b  
  order   by   字段b

发表者:zjcxc

select   *   from   表   a  
  order   by   (select   count(*)   from   表   where   b=a.b)   desc

发表者:pbsql

select   *   from   t   a  
      order   by   (select   count(*)   from   t   where   datediff(day,dt,a.dt)=0)   desc

发表者:mengzulin

(select   a.*   from   a  
  inner   join   (select   b   ,   count(b)   as   [count]     from   a)   b   on   a.b=b.b  
  order   by   b.[count]   desc  
 

发表者:jixiaojie

--参照邹老大的  
   
  select   *   from   temp   a  
  order   by   (select   count(*)   from   temp   where   convert(varchar,b,110)=convert(varchar,a.b,110))   desc

.
处理 SSI 文件时出错
© 2006-2008 All Rights Reserved