From a184ddd80b220c085eadf7b0b283337d67b5a44f Mon Sep 17 00:00:00 2001 From: Wangch29 <115294077+Wangch29@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:50:29 -0500 Subject: [PATCH] add new sqltest partition by combined with rank. --- test/sql/p3.20-window-function.slt | 35 +++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/test/sql/p3.20-window-function.slt b/test/sql/p3.20-window-function.slt index 1d9258b23..1ad179bc7 100644 --- a/test/sql/p3.20-window-function.slt +++ b/test/sql/p3.20-window-function.slt @@ -97,4 +97,37 @@ select sum(v2) over (partition by v1 order by v2), sum(v2) over (order by v2) fr 300 300 600 600 400 1000 -900 1500 \ No newline at end of file +900 1500 + +# Create table t3 +statement ok +create table t3(v1 int, v2 int); + +# Insert something +query +insert into t3 values (2, 3), (3, 2), (1, 2), (3, 1), (3, 1), (2, 2), (1, 1),(1, 3), (3, 1), (2, 1), (3, 1), (1, 1); +---- +12 + +# partition by combined with rank +query rank_partition +select * +from ( + select v1, v2, rank() OVER (PARTITION BY v1 ORDER BY v2) AS rank + FROM t3 +) as subquery +order by v1, rank; +---- +1 1 1 +1 1 1 +1 2 3 +1 3 4 +2 1 1 +2 2 2 +2 3 3 +3 1 1 +3 1 1 +3 1 1 +3 1 1 +3 2 5 +