← All errors

SQLCODE -208

SQL0208 ORDER BY column not in result table

IBM message text
ORDER BY column &1 or expression not in result table.
SQLCODE
-208
SQLSTATE
42707

Most common cause

With UNION, EXCEPT or INTERSECT, ORDER BY uses a column that is not a named column of the result.

Other causes

  • The matching columns of the two SELECTs have different names, so the result column has no name.

How to fix it

Give the column the same alias in every SELECT, or order by position number (ORDER BY 2).

Text and codes from IBM documentation for 7.6. Checked on .