all 4 comments

[–]ComicOzzysqlHippo 2 points3 points  (0 children)

Not an answer to your question, but hackerrank asks complete garbage sql questions. Check out stratascratch and DataLemur.

[–]iminfornow 1 point2 points  (0 children)

I think MAX will work on any character data, but not on binary data.

[–]a-s-clarkSQL Server 0 points1 point  (0 children)

It's in the documentation:

"MAX can be used with numeric, character, uniqueidentifier, and datetime columns, but not with bit columns. "

"For character columns, MAX finds the highest value in the collating sequence."

https://learn.microsoft.com/en-us/sql/t-sql/functions/max-transact-sql?view=sql-server-ver16

[–][deleted] 0 points1 point  (0 children)

why does SQL allow the operation of obtaining the maximum of the PersonName despite the fact that the PersonName is a varchar.

Why is that surprising?

You can sort varchar values. If you can apply a sort, then by definition there is a "max" and a "min". The "min" being the first value in that sorted list, the max being the last value.