SELECT DISTINCT * FROM ( SELECT a.Title, a.ID FROM TableA a LEFT JOIN TableB b ON a.ID = b.XID) c ORDER BY CASE WHEN c.ID > 10 THEN c.Title ELSE c.ID END ASC
And if I move
DISTINCT to nested select, then both
Title should be in same type, e.g:
INT, but they are not.
Title are in the selected columns, what is the problem?
Also with this change
CASE WHEN 1 <> 1 query runs without problem.