Roman Puchkovskiy wrote: > > I run Derby 10.3.2.1. A query that seems to be correct (and worked in > previous versios) now produces an error. [ snip ] > Error is produced: "The ORDER BY clause may not contain column 'pos', since > the query specifies DISTINCT and that column does not appear in the query > result." > > But "pos" column is in 'select' clause! > > This query did not produce error in 10.1.2.1 and 10.3.1.4. The code that throws this error was deliberately added as part of DERBY-2351 (which went into 10.3.1.4), and comments in that Jira suggest that there is a valid reason for doing so. But that said, the fact that the query executes if you use the alias instead of the actual column name seems odd. If the query is supposed to be rejected for the sake of correctness, then why is it that use of the alias makes it "safe" while use of the direct column name makes it "unsafe"? Is that the way things are _supposed_ to work, or is there a glitch somewhere? These are not necessarily questions for you (Roman), just questions that occurred me in re-reading this thread. Apologies if I'm missing something obvious. And of course, if using the alias does *not* make the query run, then ignore everything I've just written... Army