34,591
社区成员
发帖
与我相关
我的任务
分享
select
(select sum(haha) from aaa) as a,
(select sum(heihei) from bbb) as b
select sum(haha),(select sum(heihei) from bbb) from aaa
select sum(aaa.haha), sum(bbb.heihei)
from aaa
left join bbb on aaa.id = bbb.id
select sum(haha),sum(heihei) from aaa
CREATE TABLE [dbo].[aaa](
[id] [int] IDENTITY(1,1) NOT NULL,
[haha] [int] NULL,
[heihei] [int] NULL
)
insert into aaa(haha,heihei) values(1 ,2)
insert into aaa(haha,heihei) values(2 ,3)
insert into aaa(haha,heihei) values(3 ,4)
go
select sum(haha) , sum(heihei) from aaa
drop table aaa
/*
----------- -----------
6 9
(所影响的行数为 1 行)
*/
select sum(haha) , sum(heihei) from aaa
select sum(haha),sum(heihei) from aaa
select sum(haha),sum(heihei) from aaa