Sort record size of nnnnn bytes is too big
This error occurs when the size of an intermediate or final row in a GROUP BY or ORDER BY statement doesn't fit into 64kB (a few bytes less actually). You might be using some UDF in GROUP BY or ORDER BY that outputs VARCHAR(32765) or CHAR(32765) - which is quite common for string UDFs. You could try to redeclare those UDFs and reduce the size of output to see if it helps. If you are joining many tables just to get some additional lookup data, you can use MAX or MIN to shorten the group by list. See FAQ #304 for example.
This can also happen if you try to use DISTINCT on columns whose combined size exceeds 64kB. If this is the case, you can work around it by rewriting the query to use EXISTS instead of DISTINCT to detect the duplicates.