so I have to write a CSV in Java by reading a query in PostgreSQL. The problem is the csv must have a certain format and i can't get to that. I am trying to get this done in postgresql, but if it's not possible i also accept ideas on how to solve it in Java.
I tried a lot of group by syntaxes but it just does not work properly, at this point I'm not even sure it's doable in postgresql but I'd like to do it this way if it's possible. Let's say I want to see all the students from taking a class grouped. I thought it's because the date, but i removed it and it doesn't makes a difference.
SELECT classID,
firstName || secondName || fathersName,
studentGender,
to_char(studentBirthDate, 'DD.MM.YYYY HH24:mm:ss')
FROM Student, Class
WHERE studentGender = Male
GROUP BY classID, firstName, secondName, fathersName, studentGender, sutdentBirthdate
ORDER BY studentID;
I expected following result:
1, PaulLoganDan, JakeIanGolagan, JohnDoeNick, Male, NotSureHere
2, MatthewJoshuaSamuel, JosephJamesBenjamin, AdamLukeHarry, LewisNathanBrad, Male, NotSureHere
What i got:
1, PaulLoganDan, Male, 1.1.1999 \n
1, JakeIanGolagan, Male, 2.2.1999 \n
1, JohnDoeNick, Male, 3.3.1999 \n
2, MatthewJoshuaSamuel, Male, 4.4.1999 \n
2, JosephJamesBenjamin, Male, 5.5.1999 \n
2, AdamLukeHarry, Male, 6.6.1999 \n
2, LewisNathanBrad, Male, 7.7.1999 \n