Fixed a copy paste errors and filtered out all edges with form (x,x)

Before, there were edges in this form (x,x) included but they shouldn't be included.
Ist von mir und Stefan, nicht Stephan :P
Merge pull request #5 from mcwise/patch-2

Ist von mir und Stefan, nicht Stephan :P
Merge pull request #4 from mcwise/patch-1

Fixed a copy paste errors and filtered out all edges with form (x,x)
Mit Peter und Nilan nochmals korrekturgelesen.
definition von strict
Merge branch 'master' of github.com:MartinThoma/LaTeX-examples
misc
Musterloesung existiert bereits
corrected SQL statement

- it's totally uneeded to join the FROM table once again
- I do not know about specifying multiple tables in one JOIN, it might be wrong, but at least it's (same as using CROSS JOIN syntax with multiple FROM tables) at least bad behaviour
- omitting the ON clause when using JOIN is afaik not optional in the SQL standard. MySQL allows it, but then uses CROSS JOIN. Here you either want NATURAL JOIN or JOIN with ON clause. I prefer JOIN with explicit ON clauses all the time (because I never call my columns Berater.berater_id, but Berater.id and in foreign key definitions then Foo.berater_id), but since in the lectures NATURAL JOIN was so often prefered, I thought about using that. In my own exam, I will always use ON clause, because I am more used to that and I will not run into troubles if there are two columns with the same name, which is exactly the problem here. There are two tables with column "name". The second NATURAL JOIN would fail, because it would try to not only JOIN Kunden2Berater.kunden_id with Kunden.kunden_id, but also Berater.name with Kunden.name.
Thus, I'd recommend to always use explicit ON statements.
Merge pull request #7 from taikano/patch-1

corrected SQL statement
compiled PDF
removed TODO
left join sufficient

A LEFT (OUTER) JOIN is totally sufficient here, you do not want to have one Berater NULL with about 10 customers (because some customers do not have a Berater).

Moreover, when using the altered version as expected (i.e. the one with Kunden2Berater table) there is no column Kunden.berater_id anymore. You thus have to join Kunden2Berater.

I have NOT checked the COUNT throroughly, but according to my understand you will have to count on one of the Kunden2Berater columns, because COUNT() will ignore NULL columns and this is what we want. If LEFT JOIN returned a row where there are no columns on the right side, the count shall give NULL. Yet, I have to admit that I do not understand COUNT() too well. The DISTINCT is then unneeded, because we GROUP BY berater_id and the kunden_id for each berater itself will already be unique. So please do not take the COUNT statement for granted now, it's untested. http://www.techonthenet.com/sql/count.php
Merge pull request #8 from taikano/patch-2

left join sufficient
textsetzung
MAX in WHERE not possible

You cannot use MAX() in a WHERE clause, instead use a subquery.

The ORDER BY is also unneeded, because we only select the maximum. So what to order, there is only one number (even if multiple entries with the same number).
Merge pull request #9 from taikano/patch-3

MAX in WHERE not possible
compiled PDF
Added further explanation