简体   繁体   中英

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. 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. 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. I've done it in the pass using SSIS but I'm sure other tools could handle it.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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