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

Sorting on COUNT with OR and GROUP BY delivers wrong results.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 10.3.1.4
    • 10.3.3.0, 10.4.1.3
    • SQL
    • None
    • Eclipse 3.2.2; java 1.5.0_11;
    • Urgent
    • Regression

    Description

      The result of the select is not sorted in "order by COUNT DESC" or "order by COUNT ASC"

      create table yy (a double, b double);

      insert into yy values (2, 4);
      insert into yy values (5, 7);
      insert into yy values (2, 3);
      insert into yy values (2, 3);
      insert into yy values (2, 3);
      insert into yy values (2, 3);
      insert into yy values (9, 7);

      select b, COUNT AS "COUNT_OF", SUM(b) AS "sum b"
      from yy
      where a = 5 or a = 2
      group by b
      order by COUNT asc

      – same result as:

      select b, COUNT AS "COUNT_OF", SUM(b) AS "sum b"
      from yy
      where a = 5 or a = 2
      group by b
      order by COUNT desc

      Attachments

        1. d3231_v2.patch
          2 kB
          A B
        2. order_by_bug.diff.txt
          2 kB
          Manish Khettry

        Issue Links

          Activity

            People

              mkhettry Manish Khettry
              peterb Peter Balon
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: