如何插入从另一个表中提取的表记录 [英] How to do INSERT into a table records extracted from another table

查看:31
本文介绍了如何插入从另一个表中提取的表记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个查询,该查询从表中提取和转换数据,然后将这些数据插入到另一个表中.是的,这是一个数据仓库查询,我正在 MS Access 中进行.所以基本上我想要一些这样的查询:

I'm trying to write a query that extracts and transforms data from a table and then insert those data into another table. Yes, this is a data warehousing query and I'm doing it in MS Access. So basically I want some query like this:

INSERT INTO Table2(LongIntColumn2, CurrencyColumn2) VALUES
  (SELECT LongIntColumn1, Avg(CurrencyColumn) as CurrencyColumn1 FROM Table1 GROUP BY LongIntColumn1);

我尝试过,但收到一条语法错误消息.

I tried but get a syntax error message.

如果你想这样做,你会怎么做?

What would you do if you want to do this?

推荐答案

无VALUES",无括号:

No "VALUES", no parenthesis:

INSERT INTO Table2(LongIntColumn2, CurrencyColumn2)
SELECT LongIntColumn1, Avg(CurrencyColumn) as CurrencyColumn1 FROM Table1 GROUP BY LongIntColumn1;

这篇关于如何插入从另一个表中提取的表记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆