tableA
时间               所有记录
2004-09-10         100tableB
时间               用户记录
2004-09-10         200
2004-09-11         100我想显示如下:
时间        所有记录     用户记录
2004-09-10  100           200
2004-09-11  空            100这条sql语句该怎么写更高效?

解决方案 »

  1.   

    select  NVL(a.sdate,b.sdate),a.allcount,b.usercount  from a full join b on a.sdate = b.sdate这是我想的最简单的写法了,但是感觉他是否效率可行?
      

  2.   

    select * from tablea b left join table a where b.时间=a.时间
      

  3.   

    更正:
    select * from tableb b left join tablea a where b.时间=a.时间建议:如果将时间改成其它形式的连接效率会高些!
    如时间更成:这种格式: 整型 200040911
      

  4.   

    B为主表left join A on  b.时间=a.时间
      

  5.   

    select A.时间 ,a.所有记录 , b.用户记录
    from tableA a , tableB b where a.时间 = b.时间( + )