0

Say, we have the following Student table:

 Name    Roll      Dept
 demo1    123      CSE
 demo2    124      CSE
 demo3    125      EEE
 demo4    126      ECE
 demo5    127      EEE
 demo6    128      ETE
 demo7    129      ETE

I want to execute a sql query on the above table such that the students of the table will be grouped into departments and each group result will be stored in a separate excel file. For example:

Excel file 1 may contain:
 Name    Roll   Dept   
 demo1    123   CSE     
 demo2    124   CSE

Excel file 2 may contain:
 Name    Roll   Dept     
 demo3    125   EEE     
 demo5    127   EEE

..... and so on.

The following query can group the students:

select Name, Roll, Dept from Student 
group by Dept;

But how can I store the group wise results into different files? I am using mySQL.

  • Knowing if you want a solution for mysql or oracle is important.. – P.Salmon Dec 02 '20 at 14:47
  • 1
    MySQL is not Oracle. Please do not tag spam. Tags have relevance and meaning here, so you should only use the ones that are actually applicable to your post. Mistagging not only defeats the intended purpose of tags, but it can waste the time of people who write an answer relevant to one of the tagged DBMSs only to find out it won't work because you're not actually using that DBMS. Please [edit] your post and remove the tag that is not applicable. – Ken White Dec 02 '20 at 14:52
  • mySQL @P.Salmon – user14216688 Dec 03 '20 at 16:49
  • Does this answer your question? [Exporting results of a Mysql query to excel?](https://stackoverflow.com/questions/10295228/exporting-results-of-a-mysql-query-to-excel) – JeffUK Dec 03 '20 at 16:54
  • I want different excel files at a time for each group by values @JeffUK – user14216688 Dec 03 '20 at 20:27

0 Answers0