db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Army <qoz...@gmail.com>
Subject Re: Derby complains on SQL that has ORDER BY that order column is not in query result, but it's there
Date Sat, 16 Feb 2008 01:11:13 GMT
Roman Puchkovskiy wrote:
> I run Derby 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 and

The code that throws this error was deliberately added as part of 
DERBY-2351 (which went into, 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 


View raw message