Why does MAX(name) FROM fake_apps return "yearfix"?

I’m curious to know how the MAX() function works on strings. I tried to MAX() fake_apps and it returned "year fix’ why so? Why not Zotice or something such?

Here’s the link to the lesson: LINK

@boardrockstar88608, welcome to the forums!

When you use the MAX() function, it is essentially taking the item that would be last when using ORDER BY ... ASC. In SQL, when strings are ordered in ascending order, they go alphabetically from A to Z (capital) and then from a to z (lowercase). You can see this in action if you query this:

FROM fake_apps
ORDER BY name;

You will notice that “Zummaline” comes before “alphalux”.

In order to use MAX() to find the case-insensitive alphabetically last name, you will want to convert the names to all upper or lower case in your query.

For example:

SELECT MAX(LOWER(name)) --or MAX(UPPER(name))
FROM fake_apps;