sql表的合并
table a
date aa
2006-11-1 10
2006-11-2 20
2006-11-3 30
table b
date bb
2006-11-1 25
2006-11-2 10
table c
date cc
2006-11-1 12
变为
table d
pub aa bb cc
2006-11-1 10 25 12
2006-11-2 20 10 0
2006-11-3 30 0 0
------解决方案----------------------改一下
--如果a表中日期不是全部的日期,用如下:
select pub.[date] as pub,
a.aa,
b.bb,
c.cc
from (select [date] from a union select [date] from b union select [date] from c) pub
left join a on pub.[date]=a.[date]
left join b on pub.[date]=b.[date]
left join c on pub.[date]=c.[date]