I have more columns, but it is only to explain.
In fact this table is an output of postgresql, but I understand that this formatting is not possible in sql (right?). Of course, I could connect with MsAccess and use its report wizard, but I'd like to learn to do without Windows alltogether. If I had a i386 machine, I could try using OpenOffice. I checked google and found tools like Gedafe and Papyrus, but cannot get Gedafe to work (I know, I have to study) and Papyrus seems to be 100% Linux-centric.
So, my question is: can I do it with a tool like sed? Or how could I do it? Working with the computer, I very often get into this kind of formatting problems. What would the best language to learn to solve problems in autonomy?

It is unclear why the first two columns change, but the other two remain the same from the first representation to the second. If this is simply an oversight, yes, sed(1) can be used to reformat it, but personally, I would find this akin to extracting my own teeth with a pair of pliers.

With whatever database you are using, you should have some form of administrative console which allows you to interact with the database by typing in SQL commands. The output of SELECT statements may be formatted well enough for your needs. If you need more control, you should be able to capture the output of the administrative console, & manipulate the output with awk(1), perl(1), or a host of other scripting tools.

If logic is required to move from the first representation above to the second, I would highly recommend awk, perl, et. al.. sed will not be able to perform sophisticated logic.

In particular, if you are wanting to format columns, look at the printf() function available in any of the scripting languages (even in Python...) as this will allow you to fix the column size even when the text in the column varies.

Well, let me tell you the whole story.
This is a small dictionary for research purposes, and I want to take away the redundant "1" and "2" simply because it becomes more readable (at least for me).
What I do now is use the "\f" format command in psql to put a "&" as a column separator, then I output the query to a file and print it out with latex. So I guess this extra formatting operation I want would be done on the output file with the "&" as column separators.

Great! It is exactly what I need!
But one question: what if the output is already formatted with the "&" as column separators? In that case if you cat the file they will be displayed as a continuous line (I will do the tabular in latex). how do I tell awk to use "&" as column separators?

...I want to take away the redundant "1" and "2" simply because it becomes more readable (at least for me).

Understandable, but depending upon how far you want to remove redundancy, you may be needing to buffer many rows (at least the number of columns you are outputting...), & the logic will grow with the sophistication. Nevertheless, that is a decision you will need to make. It all depends upon whether the result is worth your time & effort.

Yet going back to your original question, I don't see that you will be able to do this kind of formatting in sed(1). The point being is that you are on a slippery slope of formatting wants & desires which will ultimately force you to resort to awk(1), perl(1), etc. soon, so you might as well be finding something more powerful than sed(1) now.

If you are reticent to move to a different tool due to unfamiliarity, google for "xyz tutorial", & you should be able to find enough to get started. This is particularly true of awk, & as I recall, there are some reasonable tutorials over at IBM's DeveloperWorks site (where ironically, there are tutorials for sed as well... ).

No, sorry, I have to correct, this is not "exactly" what I need, but something very similar.
I need something more esotheric, that is I don't want to declare the values in the first two columns. The script should judge if the following rows have the same values and keep only the first one.
Maybe I'm asking too much.