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

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

问题描述

我正在尝试编写一个查询,该查询从一个表中提取和转换数据,然后将这些数据插入另一个表中.是的,这是一个数据仓库查询,我正在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天全站免登陆