我有UCP
表和SalesPerProduct
包含数据
我想插入SalesPerProduct
来自UCP
条件选择
当我选择它工作正常我使用此查询
select t.ID, sum(Qty) as sum_BioxellTerritories ,
sum(SalesResult) as Sales , BioxellTerritories
from UCP as t group by ID ,BioxellTerritories
ORDER BY BioxellTerritories ASC
当我使用insert
时insert into SalesPerProduct
(ProductID , Volume , Sales ,Territories )values
select t.ID, sum(Qty) as sum_BioxellTerritories , sum(SalesResult)
as Sales , BioxellTerritories from UCP as t group by ID ,BioxellTerritories ORDER BY BioxellTerritories ASC
我没有为我工作..对于数据样本这是我要插入的选择结果
答案 0 :(得分:2)
您只想要insert . . . select
:
insert into SalesPerProduct (ProductID, Volume, Sales, Territories )
select t.ID, sum(Qty) as sum_BioxellTerritories, sum(SalesResult)
as Sales, BioxellTerritories
from UCP as t
group by ID, BioxellTerritories
order by BioxellTerritories ASC ;
VALUES
关键字是不必要的。
答案 1 :(得分:1)
查看[Parsed_atrim_0 @ 00000000000c8700] Media type mismatch between the 'Parsed_atrim_0' filter output pad 0 (audio) and the 'Parsed_concat_2' filter input pad 0 (video)
[AVFilterGraph @ 0000000002435260] Cannot create the link atrim:0 -> concat:0
Error initializing complex filters.
Invalid argument
语句的此参考:
https://www.w3schools.com/sql/sql_insert_into_select.asp
简而言之,在INSERT INTO SELECT
语句与VALUES
合并时,您不需要SELECT
关键字。
如果您仍有问题我建议发布您的表格定义,以便人们可以为您提供进一步的帮助。