in reply to sql output format
That looks pretty simple to fix, but it's impossible to guess how.
So: how is this output produced?
(which (r)dbms, which tool (if any), what perl code, what SQL code?)