初学mssql,有个tsql的问题求教各位:使用以下语句进行查询
select sum(aaa1),sum(aaa2) from book where bbb = '条件'接着要在表table1中插入一条记录,对a1,a2分别赋值查询到的结果
INSERT INTO [xx].[dbo].[table1]
( [a1],[a2])
VALUES
(???????)以上问号部分要如何写呢?
也就是如何取得sum(aaa1),sum(aaa2)的值并将他们写入表中?
select sum(aaa1),sum(aaa2) from book where bbb = '条件'接着要在表table1中插入一条记录,对a1,a2分别赋值查询到的结果
INSERT INTO [xx].[dbo].[table1]
( [a1],[a2])
VALUES
(???????)以上问号部分要如何写呢?
也就是如何取得sum(aaa1),sum(aaa2)的值并将他们写入表中?
from book where bbb = '条件'
select sum(aaa1),sum(aaa2) from book where bbb = '条件'
insert into [xx].[dbo].[table1] (col1,col2)
select sum(aaa1),sum(aaa2)
from book where bbb = '条件'
INSERT INTO [xx].[dbo].[record]
( [aaa1])
VALUES
(????)
from book where bbb = '条件'
INSERT INTO [xx].[dbo].[record]
([aaa1]) VALUES (@aaa)
SELECT SUM([aaa1]) FROM [xx].[dbo].[record]