You can try following the below steps:
1. Select a distinct username from the database table.
2. Now, to iterate on each of the usernames add a tFlowToIterate component.
3. By using an iterate link, connect a tJava component.
4. Then you can assign the username to context variable by using tJava component. Then type: context.username=row1.username.
5. Now, connect the tJava component to a table component by using 'OnComponentOk' trigger to select data from the table based on the where condition: username='"+context variable+"'.
6. Finally, you can write data into a file. Provide the filename as: "<path>\"+context.username.
Hope this helps.