db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Shuttlewood <andrew.shuttlew...@futureroute.co.uk>
Subject Distinct subselect bug?
Date Mon, 27 Jun 2005 11:47:39 GMT
While trying out some queries recently, we came across some weird
issues.

We sometimes work off of queries that are provided by the user, so we
heavily use subselects. This is a recent one

select distinct(col1) from (select col1,col2,col3,col4 from table) t

Interestingly enough, this doesn't actually work.

I've attached a sample CSV file to demonstrate some sample data.

With this query

select distinct name from (select name,ID from names) n

And a schema of ID:string, Name: String

I get

"Carl"
"Anna"
"Julian"
"Julian"
"Julian"
"Andrew"
"Andrew"
"Andrew"
"Ben"
"George"
"George"
"George"
etc.

if I omit the other column (ie, 'select distinct name from (select name
from names) n' then it works fine, and it also works okay if I flatten
the query.

It ALSO works okay if I do an ORDER BY on the top entry. ie

select distinct name from (select name,ID from names) n ORDER BY name

I assume this is a bug?
names.csv: attached

Mime
View raw message