表1
count      date
   3      20090201
   5      20090203
   4      20090204
   3      20090205
我想得到的查询结果是
 count      date
   3      20090201
   0      20090202
   5      20090203
   4      20090204
   3      20090205   
我的sql语句是
select count,date
from 表1
where date between '20090201' and '20090205'
group by date但结果没有红色部分的数据!!!
我用的是ACCESS数据库。

解决方案 »

  1.   


    SQL> select to_date('2009-2-1', 'yyyy-mm-dd') + level "Date"
      2    from dual
      3    connect by level <= 10;Date
    ----------
    2009-02-02
    2009-02-03
    2009-02-04
    2009-02-05
    2009-02-06
    2009-02-07
    2009-02-08
    2009-02-09
    2009-02-10
    2009-02-1110 rows selected.select nvl(b.count, 0),a."date"
    from (select to_date('2009-2-1', 'yyyy-mm-dd') + level “Date" from dual connect by level <= 10)a
    left join 表1 on a."Date"=表1."date"
    where a."Date" between '2009-02-01' and '2009-02-05'
    group by a."Date"