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

Wrong results when using STDDEV_SAMP() and view

    XMLWordPrintable

Details

    Description

      create table t1(i int);
      insert into t1 values  (1),(2),(3),(4),(5);
       
      select stddev_samp(i) from t1;
      create view v1 as select stddev_samp(i) from t1;
      select * from v1;
      

      MariaDB [test]> select stddev_samp(i) from t1;
      +----------------+
      | stddev_samp(i) |
      +----------------+
      |         1.5811 |
      +----------------+
      1 row in set (0.001 sec)
       
      MariaDB [test]> create or replace view v1 as select stddev_samp(i) from t1;
      Query OK, 0 rows affected (0.009 sec)
       
      MariaDB [test]> select * from v1;
      +----------------+
      | stddev_samp(i) |
      +----------------+
      |         1.4142 |
      +----------------+
      1 row in set (0.002 sec)
      

      And with window function:

      create table t1(i int);
      insert into t1 values  (1),(2),(3),(4),(5);
       
      select stddev_samp(i) over (order by i) from t1;
      create view v1 as select stddev_samp(i) over (order by i) from t1;
      select * from v1;
      

      MariaDB [test]> select stddev_samp(i) over (order by i) from t1;
      +----------------------------------+
      | stddev_samp(i) over (order by i) |
      +----------------------------------+
      |                             NULL |
      |                           0.7071 |
      |                           1.0000 |
      |                           1.2910 |
      |                           1.5811 |
      +----------------------------------+
      5 rows in set (0.002 sec)
       
      MariaDB [test]> create view v1 as select stddev_samp(i) over (order by i) from t1;
      Query OK, 0 rows affected (0.007 sec)
       
      MariaDB [test]> select * from v1;
      +----------------------------------+
      | stddev_samp(i) over (order by i) |
      +----------------------------------+
      |                           0.0000 |
      |                           0.5000 |
      |                           0.8165 |
      |                           1.1180 |
      |                           1.4142 |
      +----------------------------------+
      5 rows in set (0.003 sec)
      
      

      Attachments

        Activity

          People

            serg Sergei Golubchik
            alice Alice Sherepa
            Votes:
            1 Vote for this issue
            Watchers:
            4 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.