我的数据库大概是这样的,每辆车通过一地方,记录车牌和通过时间
车牌号码     经过时间
浙A.23232    ....  
浙A.22532    ....
浙A.29632    ....
浙A.23232    ....  
.................
我现在要查询某一天内经过该地方数量前10名的车辆
这用sql怎么表示
sql server和oracle实现有差别吗?

解决方案 »

  1.   

    select * from table where to_char(经过时间,'yyyy-mm-dd')='2006-06-20' and rownum<=10
      

  2.   

    select 车牌号码,max(ct) 经过次数 from ( select 车牌号码,count(车牌号码) ct from table where to_char(经过时间,'yyyy-mm-dd')='2006-06-20' group by 车牌号码) 
      

  3.   

    搞错了,上面是最多次的车辆前十名如下select * from (select 车牌号码,max(ct) 经过次数 from ( select 车牌号码,count(车牌号码) ct from table where to_char(经过时间,'yyyy-mm-dd')='2006-06-20' group by 车牌号码) order by 经过次数 desc ) where rownum<11