Q:

What's the difference between these two queries?

can someone explain to me why the following queries give different results?
Note: the first query gives the correct result, but the next one does not
SELECT 
    COUNT(MONTH(datum)) Anzahl,
    MONTH(datum) monat,
    100 * COUNT(*) / (SELECT 
            COUNT(*)
        FROM
            kunde) Anteil
FROM
    kunde
GROUP BY monat

here is the other query
SELECT 
    COUNT(MONTH(datum)) Anzahl,
    MONTH(datum) monat,
    100 * COUNT(*) / COUNT(*) AS anteil
FROM
    kunde
GROUP BY monat

A:

The first one counts the grouped records and divides by all records (nested query).
The second one will do 100 * X / X, where x is the number of grouped records.

