34,590
社区成员
发帖
与我相关
我的任务
分享
create table A
(
ID int,
Name varchar(2),
Quantity int
)
go
create table B
(
ID int,
Type varchar(10),
Info varchar(10)
)
go
insert into a select 1,'A',10 union all
select 1,'b',15 union all
select 2,'a',20 union all
select 2,'b',18 union all
select 2,'c',12
go
insert into B select 1,'AAA','XXX' union all
select 2,'BBB','YYY'
go
select b.ID,Type,Info,t.Sum 'Sum(a.Quantity)' from B join
(select id,sum(quantity) 'Sum' from A group by id) t on t.id=b.id
Select b.ID,b.Type,b.Info,Sum(a.Quantity)
From A a,B b
Where a.ID=b.ID group by b.ID,b.Type,b.Info
Select b.ID,b.Type,b.Info,Sum(a.Quantity)
From A a,B b
Where a.ID=b.ID
group by b.ID,b.Type,b.Info
Select b.ID,b.Type,b.Info,Sum(a.Quantity)
from A a,B b
where a.ID=b.ID
group by b.id
Select b.ID,b.Type,b.Info,Sum(a.Quantity)
From A a,B b
Where a.ID=b.ID
group by b.ID