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

Non-selected columns for SELECT DISTINCT allowed in ORDER BY clause if ordered by expression

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 10.5.1.1
    • Fix Version/s: 10.7.1.1
    • Component/s: SQL
    • Labels:
      None
    • Issue & fix info:
      Repro attached
    • Bug behavior facts:
      Wrong query result

      Description

      How to repeat:

      ij> create table t (i integer, j integer);;
      0 rows inserted/updated/deleted
      ij> insert into t values (1,2),(1,3);
      2 rows inserted/updated/deleted
      ij> select distinct i from t order by j;
      ERROR 42879: The ORDER BY clause may not contain column 'J', since the query specifies DISTINCT and that column does not appear in the query result.
      ij> select distinct i from t order by j*2;
      I
      -----------
      1
      1

      2 rows selected

        Attachments

        1. DERBY-4371.diff
          2 kB
          Nirmal Fernando
        2. DERBY-4371-2.diff
          2 kB
          Nirmal Fernando
        3. DERBY-4371-3.diff
          4 kB
          Nirmal Fernando
        4. DERBY-4371-4.diff
          4 kB
          Nirmal Fernando
        5. derby-4371-5.diff
          5 kB
          Nirmal Fernando
        6. derby-4371-6.diff
          5 kB
          Nirmal Fernando
        7. derby-4371-7.diff
          5 kB
          Nirmal Fernando
        8. derby-4371-tests.diff
          8 kB
          Nirmal Fernando

          Issue Links

            Activity

              People

              • Assignee:
                nirmal Nirmal Fernando
                Reporter:
                bernt Bernt M. Johnsen
              • Votes:
                1 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: