所以我试图从另一个表的选择查询中插入一个表。我想我必须这样做,因为我试图对插入中的几列求和。最终,我希望这是一个将数据从临时表移动到更规范化的数据的存储过程。我得到的错误是查询中最后一个字符的语法错误。您可以提供的任何帮助或建议将不胜感激。这是我的查询:
INSERT INTO ShippingCost (WebOrder, Zone, NetAmount, EnteredWeight, BilledWeight, Carrier)
SELECT WebOrder, Zone, NetAmount, EnteredWeight, BilledWeight, Carrier
FROM
(select substring([Package Reference Number 5],4,9) as WebOrder
, zone
, sum(CAST([Net Amount] as Money)) as NetAmount
, sum(CAST([Entered Weight] as decimal)) as EnteredWeight
, sum(CAST([Billed Weight] as INT)) as BilledWeight
, 'UPS' as Carrier
from UpsStaging
where [Package Reference Number 5] LIKE 'WEB%[^0-9]%'
group by [Package Reference Number 5],zone
)