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

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 10.5.1.1
    • 10.7.1.1
    • SQL
    • None
    • Repro attached
    • 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-tests.diff
          8 kB
          Nirmal Fernando
        2. derby-4371-7.diff
          5 kB
          Nirmal Fernando
        3. derby-4371-6.diff
          5 kB
          Nirmal Fernando
        4. derby-4371-5.diff
          5 kB
          Nirmal Fernando
        5. DERBY-4371-4.diff
          4 kB
          Nirmal Fernando
        6. DERBY-4371-3.diff
          4 kB
          Nirmal Fernando
        7. DERBY-4371-2.diff
          2 kB
          Nirmal Fernando
        8. DERBY-4371.diff
          2 kB
          Nirmal Fernando

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            nirmal Nirmal Fernando
            bernt Bernt Johnsen
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment