Sql 错误-插入的表达式多于目标列
我正在尝试将订单数量插入storiacloud.schl\u storia\u school\u status\u try。计算在另一个表storiacloud.vw\u storia\u oms\u orders中完成。问题是它也在尝试插入school_ucn,但我只是将其用于groupby,不想插入它。有人能帮忙吗Sql 错误-插入的表达式多于目标列,sql,sql-server,Sql,Sql Server,我正在尝试将订单数量插入storiacloud.schl\u storia\u school\u status\u try。计算在另一个表storiacloud.vw\u storia\u oms\u orders中完成。问题是它也在尝试插入school_ucn,但我只是将其用于groupby,不想插入它。有人能帮忙吗 INSERT INTO storiacloud.schl_storia_school_status_try (no_of_orders) select school_ucn,co
INSERT INTO storiacloud.schl_storia_school_status_try
(no_of_orders)
select school_ucn,count(otc_order_number)
from storiacloud.vw_storia_oms_orders
group by school_ucn;
您只需将其从“选择”菜单中删除即可:
INSERT INTO storiacloud.schl_storia_school_status_try (no_of_orders)
select count(otc_order_number)
from storiacloud.vw_storia_oms_orders
group by school_ucn;
它仍然会分组,只是不会报告。不过,我不确定在表格中使用一堆随机数是什么意思 。。。或者在INSERT的列列表中添加缺少的列:
INSERT INTO storiacloud.schl_storia_school_status_try
(no_of_orders, [YOUR_NB_ORDER_COLUMN] )
select school_ucn,count(otc_order_number)
from storiacloud.vw_storia_oms_orders
group by school_ucn;
只需从SELECT中删除不需要的列。但是,如果没有与它们相关的学校的背景,这些计数又有什么用呢?没有任何东西会出现在没有秩序的情况下,比如storiacloud.schl\u storia\u school\u try。。新查询插入storiacloud.schl_storia_school_status_try no_of_orders从storiacloud.vw_storia_oms_orders中选择countotc_order_number作为内部联接storiacloud.schl_storia_school_status_try as b on a.school_ucn=b.ucn group by school_ucn;谢谢,我已经添加了学校之间的关系,但是消息说插入storiacloud.schl\u storia\u school\u status\u try successful 1829行受影响的执行时间:1.25s