Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.2(EOL)
Description
Note: results below are from 10.2 348ccb6f038a6c1
create table t1 (i int); |
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); |
MariaDB [test]> select i, first_value(i) OVER ( order by i rows between current row and current row ) from t1; |
+------+-----------------------------------------------------------------------------+ |
| i | first_value(i) OVER ( order by i rows between current row and current row ) | |
+------+-----------------------------------------------------------------------------+ |
| 1 | 1 |
|
| 2 | 1 |
|
| 3 | 1 |
|
| 4 | 1 |
|
| 5 | 1 |
|
| 6 | 1 |
|
| 7 | 1 |
|
| 8 | 1 |
|
| 9 | 1 |
|
| 10 | 1 |
|
+------+-----------------------------------------------------------------------------+ |
10 rows in set (0.00 sec) |
NTH_VALUE works fine:
MariaDB [test]> select i, nth_value(i,1) OVER ( order by i rows between current row and current row ) from t1; |
+------+-----------------------------------------------------------------------------+ |
| i | nth_value(i,1) OVER ( order by i rows between current row and current row ) | |
+------+-----------------------------------------------------------------------------+ |
| 1 | 1 |
|
| 2 | 2 |
|
| 3 | 3 |
|
| 4 | 4 |
|
| 5 | 5 |
|
| 6 | 6 |
|
| 7 | 7 |
|
| 8 | 8 |
|
| 9 | 9 |
|
| 10 | 10 |
|
+------+-----------------------------------------------------------------------------+ |
10 rows in set (0.00 sec) |
PostgreSQL 9.4 returns the same result for both queries:
postgres=# select i, first_value(i) OVER ( order by i rows between current row and current row ) from t1; |
i | first_value
|
----+-------------
|
1 | 1
|
2 | 2
|
3 | 3
|
4 | 4
|
5 | 5
|
6 | 6
|
7 | 7
|
8 | 8
|
9 | 9
|
10 | 10
|
(10 rows) |
postgres=# select i, nth_value(i,1) OVER ( order by i rows between current row and current row ) from t1; |
i | nth_value
|
----+-----------
|
1 | 1
|
2 | 2
|
3 | 3
|
4 | 4
|
5 | 5
|
6 | 6
|
7 | 7
|
8 | 8
|
9 | 9
|
10 | 10
|
(10 rows) |
Attachments
Issue Links
- relates to
-
MDEV-9896 Testing for window functions
- Open