If you use a function that returns a value whose data type is different from the column’s and sort the result based on the alias, the ORDER BY clause will sort the result set based on the return type of the function, which may not work as expected. For example, if you use the DATE_FORMAT function to format the date values and sort the result set based on the strings returned by the DATE_FORMAT function, the order is not always correct.