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

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 10.2.1.6, 10.2.2.0, 10.3.1.4
    • 10.3.3.0, 10.4.1.3, 10.5.1.1
    • SQL
    • None
    • Any
    • 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. d2351_aliasing_checkQualifiedName.diff
          11 kB
          Bryan Pendleton
        2. d2351_aliasing.diff
          9 kB
          Bryan Pendleton
        3. d2351_aliasing.diff
          7 kB
          Bryan Pendleton
        4. derby_2351_v2.diff
          10 kB
          Bryan Pendleton
        5. derby_2351.diff
          9 kB
          Bryan Pendleton
        6. modifySynonymResults.diff
          12 kB
          Bryan Pendleton
        7. releaseNote.html
          6 kB
          Richard N. Hillegas
        8. releaseNote.html
          6 kB
          Bryan Pendleton
        9. releaseNote.html
          4 kB
          Bryan Pendleton
        10. reproTests.diff
          5 kB
          Bryan Pendleton

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: