我有两张表A和B
A表只有一列,都是时间列比如:
day_date
2010-11-01
2010-11-02

2010-11-31
共有31行
表B中只有23行,但有两列,第一列是时间列,第二列是数值,如下:
day_date    count
2010-11-02  12
2010-11-03  15

2010-11-29  13
共23行
我现在把表A和表B以时间做关联查询
select A.day_date,B.count from A,B where A.day_date=B.day_date(+)
为什么出现的结果中count列会全部为空呢?

解决方案 »

  1.   


    ------么问题啊。。是不是你的plsql d默认显示只有几列啊。。你点下那个绿色的箭头看看呢
    SQL> 
    SQL> with a as
      2  (
      3  select to_date('2010-11-01','yyyy-mm-dd')+rownum-1 day_date from dual connect by rownum<=30
      4  ),b as
      5  (
      6  select to_date('2010-11-02','yyyy-mm-dd')+rownum-1 day_date,10+rownum count from dual connect by rownum<=20
      7  )
      8  select A.day_date, B.count from A, B where A.day_date = B.day_date(+)
      9  /DAY_DATE         COUNT
    ----------- ----------
    2010-11-2           11
    2010-11-3           12
    2010-11-4           13
    2010-11-5           14
    2010-11-6           15
    2010-11-7           16
    2010-11-8           17
    2010-11-9           18
    2010-11-10          19
    2010-11-11          20
    2010-11-12          21
    2010-11-13          22
    2010-11-14          23
    2010-11-15          24
    2010-11-16          25
    2010-11-17          26
    2010-11-18          27
    2010-11-19          28
    2010-11-20          29
    2010-11-21          30DAY_DATE         COUNT
    ----------- ----------
    2010-11-29  
    2010-11-26  
    2010-11-1   
    2010-11-24  
    2010-11-23  
    2010-11-22  
    2010-11-25  
    2010-11-30  
    2010-11-28  
    2010-11-27  30 rows selectedSQL> 
      

  2.   

    2楼的兄弟,我试了下你的代码确实没有问题,终于排查出来了,我都快疯了,从昨晚一直研究到现在
    原因在于格式化日期的时候不小心在后面多了个空格,于是日期怎么都相等不了,吐血
    'yyyy-mm-dd'给不小心写成'yyyy-mm-dd '了啊啊啊~~崩溃中