慕侠2389804
您有两种语法选项:选项1CREATE TABLE Table1 (
id int identity(1, 1) not null,
LongIntColumn1 int,
CurrencyColumn money)CREATE TABLE Table2 (
id int identity(1, 1) not null,
LongIntColumn2 int,
CurrencyColumn2 money)INSERT INTO Table1 VALUES(12, 12.00)INSERT INTO Table1 VALUES(11, 13.00)INSERT INTO Table2SELECT LongIntColumn1, Avg(CurrencyColumn) as CurrencyColumn1 FROM Table1 GROUP BY LongIntColumn1选项2CREATE TABLE Table1 (
id int identity(1, 1) not null,
LongIntColumn1 int,
CurrencyColumn money)INSERT INTO Table1 VALUES(12, 12.00)INSERT INTO Table1 VALUES(11, 13.00)SELECT LongIntColumn1, Avg(CurrencyColumn) as CurrencyColumn1INTO Table2FROM Table1GROUP BY LongIntColumn1请记住,选项2将创建一个只包含投影列(SELECT上的列)的表。