Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-30776

AVG over incorrect results from a inline view

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.5.17, 11.0.1, 10.3(EOL), 10.4(EOL), 10.5, 10.6, 10.7(EOL), 10.8(EOL), 10.9(EOL), 10.10(EOL), 10.11
    • 10.5, 10.6
    • Optimizer

    Description

      MariaDB [beta]> select s, lap, avg(s)over() -- , avg(lap)over()
          ->   from (
          ->  select seq s , seq + floor(rand(0)*(2)-1) lap
          ->    from seq_1_to_5
          -> ) as a
          -> order by s
          -> ;
      +---+-----+--------------+
      | s | lap | avg(s)over() |
      +---+-----+--------------+
      | 0 |   3 |       5.0000 |
      | 0 |   3 |       5.0000 |
      | 0 |   5 |       5.0000 |
      | 0 |   0 |       5.0000 |
      | 0 |   2 |       5.0000 |
      +---+-----+--------------+
      5 rows in set (0.002 sec)
      

      Correct result:

      +---+-----+----------------+
      | s | lap | avg(seq)over() |
      +---+-----+----------------+
      | 1 |   0 |         3.0000 |
      | 2 |   2 |         3.0000 |
      | 3 |   3 |         3.0000 |
      | 4 |   3 |         3.0000 |
      | 5 |   5 |         3.0000 |
      +---+-----+----------------+
      5 rows in set (0.000 sec)
      

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            rafu Timo Raitalaakso
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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