Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-2351

ORDER BY with expression with distinct in the select list returns incorrect result

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.2.1.6, 10.2.2.0, 10.3.1.4
    • Fix Version/s: 10.3.3.0, 10.4.1.3, 10.5.1.1
    • Component/s: SQL
    • Labels:
      None
    • Environment:
      Any
    • Issue & fix info:
      Release Note Needed

      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

        1. releaseNote.html
          6 kB
          Richard N. Hillegas
        2. releaseNote.html
          6 kB
          Bryan Pendleton
        3. releaseNote.html
          4 kB
          Bryan Pendleton
        4. modifySynonymResults.diff
          12 kB
          Bryan Pendleton
        5. d2351_aliasing_checkQualifiedName.diff
          11 kB
          Bryan Pendleton
        6. d2351_aliasing.diff
          9 kB
          Bryan Pendleton
        7. d2351_aliasing.diff
          7 kB
          Bryan Pendleton
        8. derby_2351_v2.diff
          10 kB
          Bryan Pendleton
        9. derby_2351.diff
          9 kB
          Bryan Pendleton
        10. reproTests.diff
          5 kB
          Bryan Pendleton

          Issue Links

            Activity

              People

              • Assignee:
                bryanpendleton Bryan Pendleton
                Reporter:
                yipng Yip Ng
              • Votes:
                1 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: