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 ID
and Title
should be in same type, e.g: INT
, but they are not.
Both ID
and Title
are in the selected columns, what is the problem?
Also with this change CASE WHEN 1 <> 1
query runs without problem.
then both ID and Title should be in same type, e.g: INT
- what makes you say that?DISTINCT
with anINTEGER
and aVARCHAR
for example! p.s. welcome to the forum! :-)