I was browsing a "SQL cookbook" to get some inspiration for SQL exercises when I came across a chapter on p*vot tables. The terror...

Apparently, you may want to get from this:

java developernick
java developerjenny

to this:

java developerdbaanalyst
jenny george

Well, don't! The first table represents a relation, the second doesn't. A relation is a set of tuples -- what sort of tuple does {nick, michael, beatrice} represent?

At best, the second table is some sort of report. SQL is not a language for producing reports. Create your report in something else: a script, a spreadsheet, a word processor. Use simple SELECT ... WHERE job = ... to fetch the appropriate data for each case.

0 Responses to ugliness

  1. There are currently no comments.

Leave a Reply