Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
a37f24b9
Commit
a37f24b9
authored
Sep 09, 2016
by
Vicențiu Ciorbaru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add min/max test cases for window functions
parent
14690c70
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
146 additions
and
0 deletions
+146
-0
mysql-test/r/win_min_max.result
mysql-test/r/win_min_max.result
+97
-0
mysql-test/t/win_min_max.test
mysql-test/t/win_min_max.test
+49
-0
No files found.
mysql-test/r/win_min_max.result
0 → 100644
View file @
a37f24b9
create table t1 (
pk int primary key,
a int,
b int,
c real
);
insert into t1 values
(101 , 0, 10, 1.1),
(102 , 0, 10, 2.1),
(103 , 1, 10, 3.1),
(104 , 1, 10, 4.1),
(108 , 2, 10, 5.1),
(105 , 2, 20, 6.1),
(106 , 2, 20, 7.1),
(107 , 2, 20, 8.15),
(109 , 4, 20, 9.15),
(110 , 4, 20, 10.15),
(111 , 5, NULL, 11.15),
(112 , 5, 1, 12.25),
(113 , 5, NULL, 13.35),
(114 , 5, NULL, 14.50),
(115 , 5, NULL, 15.65),
(116 , 6, 1, NULL),
(117 , 6, 1, 10),
(118 , 6, 1, 1.1),
(119 , 6, 1, NULL),
(120 , 6, 1, NULL),
(121 , 6, 1, NULL),
(122 , 6, 1, 2.2),
(123 , 6, 1, 20.1),
(124 , 6, 1, -10.4),
(125 , 6, 1, NULL),
(126 , 6, 1, NULL),
(127 , 6, 1, NULL);
select pk, a, b, min(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) as min,
max(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) as max
from t1;
pk a b min max
101 0 10 10 10
102 0 10 10 10
103 1 10 10 10
104 1 10 10 10
105 2 20 20 20
106 2 20 20 20
107 2 20 10 20
108 2 10 10 20
109 4 20 20 20
110 4 20 20 20
111 5 NULL 1 1
112 5 1 1 1
113 5 NULL 1 1
114 5 NULL NULL NULL
115 5 NULL NULL NULL
116 6 1 1 1
117 6 1 1 1
118 6 1 1 1
119 6 1 1 1
120 6 1 1 1
121 6 1 1 1
122 6 1 1 1
123 6 1 1 1
124 6 1 1 1
125 6 1 1 1
126 6 1 1 1
127 6 1 1 1
select pk, a, c, min(c) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) as min,
max(c) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) as max
from t1;
pk a c min max
101 0 1.1 1.1 2.1
102 0 2.1 1.1 2.1
103 1 3.1 3.1 4.1
104 1 4.1 3.1 4.1
105 2 6.1 6.1 7.1
106 2 7.1 6.1 8.15
107 2 8.15 5.1 8.15
108 2 5.1 5.1 8.15
109 4 9.15 9.15 10.15
110 4 10.15 9.15 10.15
111 5 11.15 11.15 12.25
112 5 12.25 11.15 13.35
113 5 13.35 12.25 14.5
114 5 14.5 13.35 15.65
115 5 15.65 14.5 15.65
116 6 NULL 10 10
117 6 10 1.1 10
118 6 1.1 1.1 10
119 6 NULL 1.1 1.1
120 6 NULL NULL NULL
121 6 NULL 2.2 2.2
122 6 2.2 2.2 20.1
123 6 20.1 -10.4 20.1
124 6 -10.4 -10.4 20.1
125 6 NULL -10.4 -10.4
126 6 NULL NULL NULL
127 6 NULL NULL NULL
drop table t1;
mysql-test/t/win_min_max.test
0 → 100644
View file @
a37f24b9
create
table
t1
(
pk
int
primary
key
,
a
int
,
b
int
,
c
real
);
insert
into
t1
values
(
101
,
0
,
10
,
1.1
),
(
102
,
0
,
10
,
2.1
),
(
103
,
1
,
10
,
3.1
),
(
104
,
1
,
10
,
4.1
),
(
108
,
2
,
10
,
5.1
),
(
105
,
2
,
20
,
6.1
),
(
106
,
2
,
20
,
7.1
),
(
107
,
2
,
20
,
8.15
),
(
109
,
4
,
20
,
9.15
),
(
110
,
4
,
20
,
10.15
),
(
111
,
5
,
NULL
,
11.15
),
(
112
,
5
,
1
,
12.25
),
(
113
,
5
,
NULL
,
13.35
),
(
114
,
5
,
NULL
,
14.50
),
(
115
,
5
,
NULL
,
15.65
),
(
116
,
6
,
1
,
NULL
),
(
117
,
6
,
1
,
10
),
(
118
,
6
,
1
,
1.1
),
(
119
,
6
,
1
,
NULL
),
(
120
,
6
,
1
,
NULL
),
(
121
,
6
,
1
,
NULL
),
(
122
,
6
,
1
,
2.2
),
(
123
,
6
,
1
,
20.1
),
(
124
,
6
,
1
,
-
10.4
),
(
125
,
6
,
1
,
NULL
),
(
126
,
6
,
1
,
NULL
),
(
127
,
6
,
1
,
NULL
);
--
sorted_result
select
pk
,
a
,
b
,
min
(
b
)
over
(
partition
by
a
order
by
pk
ROWS
BETWEEN
1
PRECEDING
AND
1
FOLLOWING
)
as
min
,
max
(
b
)
over
(
partition
by
a
order
by
pk
ROWS
BETWEEN
1
PRECEDING
AND
1
FOLLOWING
)
as
max
from
t1
;
--
sorted_result
select
pk
,
a
,
c
,
min
(
c
)
over
(
partition
by
a
order
by
pk
ROWS
BETWEEN
1
PRECEDING
AND
1
FOLLOWING
)
as
min
,
max
(
c
)
over
(
partition
by
a
order
by
pk
ROWS
BETWEEN
1
PRECEDING
AND
1
FOLLOWING
)
as
max
from
t1
;
drop
table
t1
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment