Uploaded image for project: 'MariaDB ColumnStore'
  1. MariaDB ColumnStore
  2. MCOL-393

window function in aggregate expression has wrong results

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 1.0.4
    • 1.2.3
    • DMLProc
    • None

    Description

      With the following table:

      create table opportunities (id int, accountName varchar(20), name varchar(128), owner varchar(7), amount decimal(10,2), closeDate date, stageName varchar(11)) engine=columnstore;
      

      the window query below which should in theory work gives wrong results for pct_won:

      select owner, count(*) wins, count(*) /( sum(count(*)) over ()) pct_won from opportunities group by 1;
      

      Rewriting the query to have the window function isolated in a subquery works around the issue:

       select t.owner, t.wins, t.wins / t.total pct_won from (select owner, count(*) wins, sum(count(*)) over () total from opportunities group by 1) t;
      

      Attachments

        Activity

          People

            David.Hall David Hall (Inactive)
            dthompson David Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.