有2个表A,B。A中有日期字段,包含一个月的每一天。B表有2个字段,1个是日期字段,另一个是费用字段,如果一天中有费用,那么这天只有一条记录,如果一天中没有费用,那么无此日记录。现要打印2列,第一列日期,包括一个月的每一天,第2列费用,如果某日无费用,责该日显示费用记录为空.Thanks........
date        cost
1/2/1999    200
1/3/1999    100
1/4/1999     
1/5/1999    600

解决方案 »

  1.   

    select a.date,b.cost from a left join b on  a.date=b.date
      

  2.   

    select a.date,isnull(b.cost,0) from a left join b on  a.date=b.date
      

  3.   

    select tab1.date,cost from tab1,tab2 where tab1.date =tab2.date(+)
      

  4.   

    select a.[date],cost
    from   a,b
    where  a.[date]*=b.[date]
      

  5.   

    select a.date,b.cost from a left join b where  a.date=b.date
      

  6.   

    select a.date,isnull(b.cost,0) from a left join b on  a.date=b.date