日期:2014-05-17 浏览次数:20477 次
create table TB1
(
id varchar(20) not null,
[month] int null,
[year] int null,
no1 varchar(20) null
)
create table TB2
(
id varchar(20) not null,
[month] int null,
[year] int null,
no2 varchar(20) null
)
insert into tb1
select 'po1',5,12,3000 union
select 'po2',5,12,2000 union
select 'po3',6,12,2010
insert into tb2
select 'po1',5,12,6000 union
select 'po2',5,12,7000 union
select 'po6',6,12,4000
select isnull(a.id,b.id) id, isnull(a.month,b.month) month,
isnull(a.year,b.year) year,isnull(a.no1,0) no1,isnull(b.no2,0) no2
from TB1 a full join TB2 b
on a.id=b.id
--CREATE TABLE TB1
-- (
-- id VARCHAR(20) NOT NULL ,
-- [month] INT NULL ,
-- [year] INT NULL ,
-- no1 VARCHAR(20) NULL
-- )
--CREATE TABLE TB2
-- (
-- id VARCHAR(20) NOT NULL ,
-- [month] INT NULL ,
-- [year] INT NULL ,
-- no2 VARCHAR(20) NULL
-- )
--INSERT INTO tb1
-- SELECT 'po1' ,
-- 5 ,
-- &