MySQL Basics In Pictures
  1. Type:

    SELECT party,COUNT(party) FROM name GROUP BY party;

    then press ENTER.

    The query results should look like this:

    This query answers a simple question: how many presidents were in each of the different parties?

    If you look at a portion of the query...

    SELECT party,COUNT(party) FROM name GROUP BY party;

    ...it lists the party for each president in the name table.

    Adding the other two parts...

    SELECT party,COUNT(party) FROM name GROUP BY party;

    ...changes things. Instead of listing all 20 presidents, the list will now be GROUPed into sub lists of presidents of like parties, and then COUNTed.

    In the end, you see one row for each party—a total of 5 rows. Each row contains the party name and the number of presidents affiliated with that party.