Details
Description
When distinct is in the select list and the query has order by with expression, the resultset produced contains an additional column.
ij> create table t1 (c1 int, c2 varchar(10))
0 rows inserted/updated/deleted
ij> insert into t1 values (1,'a'),(2,'b'),(3,'c');
3 rows inserted/updated/deleted
select distinct c1, c2 from t1 order by c1;
C1 |C2
----------------------
1 |a
2 |b
3 |c
3 rows selected
ij> select distinct c1, c2 from t1 order by c1+1;
C1 |C2 |3 <=====returns 3 columns, incorrect result returned
----------------------------------
1 |a |2
2 |b |3
3 |c |4
3 rows selected
Attachments
Attachments
Issue Links
- is related to
-
DERBY-2805 ASSERT failure with sane build if DISTINCT and ORDER BY are present in a query that selects from a diagnostic table function.
- Closed
- relates to
-
DERBY-3373 SQL "distinct" and "order by" needed together
- Closed
-
DERBY-2085 Misleading error message for non-matching ORDER BY clause in queries with GROUP BY.
- Closed