简体   繁体   English

如何将多个 sql 查询结果导出到 Postgresql 中的一个 Excel 文件中

[英]How to export multiple sql query results into one Excel file in Postgresql

I have two SQL queries and i am trying to output the results to multiple sheets in one excel file.我有两个 SQL 查询,我正在尝试 output 将结果发送到一个 excel 文件中的多张纸上。 Is it achievable?它可以实现吗?

First query: select sum(sal) from table1 group_by dept;

Second query: select * from table2 limit 5;

I am trying to copy the output to same excel but multiple sheets.我正在尝试将 output 复制到相同的 excel 但多张。 First query output should go to sheet1 and second query output should go to sheet2 in same excel file. First query output should go to sheet1 and second query output should go to sheet2 in same excel file.

If you are looking for out of the box functionality, no.如果您正在寻找开箱即用的功能,则不。 It is however possible using ETL tools.但是,可以使用 ETL 工具。 I've done it in the pass using SSIS but I'm sure other tools could handle it.我已经使用 SSIS 完成了它,但我确信其他工具可以处理它。

Or you could export to multiple csv files using the \copy command and then use a 3rd party (kutools) to merge them in one excel file.或者您可以使用\copy命令导出到多个 csv 文件,然后使用第 3 方(kutools)将它们合并到一个 excel 文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM