日期:2014-05-18 浏览次数:20743 次
create table TableA
(
id int,
name nvarchar(10),
phone varchar(20)
)
create table TableB
(
id int,
wage int
)
insert into TableA
select 1,'张三','123456789'
insert into TableB
select 1,1000 union all
select 1,2000 union all
select 1,3000 union all
select 1,4000 union all
select 1,5000 union all
select 1,6000 union all
select 1,7000 union all
select 1,8000 union all
select 1,9000 union all
select 1,10000 union all
select 1,11000 union all
select 1,12000
create view A
AS
select a.id ,a.name ,a.phone ,AVG (b.wage ) AS wage from TableA a,TableB b where a.id =b.id
group by a.id ,a.name ,a.phone
select * from A