If you have multiple ON clauses, you cannot specify ORDER BY as the only option in an ON clause. You must combine ORDER BY with a PARTITION BY (ANY), HASH BY, or DIMENSION clause.
If you specify an ORDER BY or LOCAL ORDER BY clause with PARTITION BY or HASH BY input, then the following is required:
- All inputs must have the same number of ORDER BY columns.
- The data types of the columns must be the same type or matched using implicit cast.