a:
select create_date1 from invoice group by create_date1create_date
2008-04-27
2008-05-15
2008-05-16 b:
select create_date2 from LoadingInvoice group by create_date2create_date
2008-04-29
2008-05-09
2008-05-16
如何得出如下结果:
create_date1      create_date2
                  2008-04-27
2008-04-29
                  2008-05-09
2008-05-15 
2008-05-16        2008-05-16

解决方案 »

  1.   

    没看明白,两个表之间有什么关系呢 ??? 比如 CreatID 等
      

  2.   

    create_date1 和 create_date2 之间的关联是通过哪个字段 
    你最后想要的结果是不是想要两个表中所有出现过的日期呢?
      

  3.   


    --> 测试数据: @a
    declare @a table (create_date datetime)
    insert into @a
    select '2008-04-27' union all
    select '2008-05-15' union all
    select '2008-05-16'
    --> 测试数据: @b
    declare @b table (create_date datetime)
    insert into @b
    select '2008-04-29' union all
    select '2008-05-09' union all
    select '2008-05-16'select create_date1=a.create_date,create_date2=b.create_date from @a a full join @b b
    on a.create_date=b.create_date
    order by isnull(a.create_date,'1900-01-01')+isnull(b.create_date,'1900-01-01')
      

  4.   

    楼上写的对,那如果用的是sqlite数据库,不支持full join,那如何写呢