You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
107 lines
1.0 KiB
Plaintext
107 lines
1.0 KiB
Plaintext
USE tpch1;
|
|
drop table if exists t;
|
|
create table t(a int, b int) engine=columnstore;
|
|
insert into t(a,b) values(1,4),(2,3),(3,2),(4,1);
|
|
select
|
|
a,
|
|
r
|
|
from (
|
|
select
|
|
a,
|
|
DENSE_RANK() OVER `w_0` as `r`
|
|
from t
|
|
WINDOW `w_0` as ( ORDER BY `b` DESC)
|
|
) t0
|
|
where r in (1,2);
|
|
a r
|
|
1 1
|
|
2 2
|
|
select
|
|
a,
|
|
r
|
|
from (
|
|
select
|
|
a,
|
|
DENSE_RANK() OVER `w_0` as `r`
|
|
from t
|
|
WINDOW `w_0` as ( ORDER BY `b` DESC)
|
|
) t0
|
|
where r not in (1,2);
|
|
a r
|
|
3 3
|
|
4 4
|
|
select
|
|
a,
|
|
r
|
|
from (
|
|
select
|
|
a,
|
|
DENSE_RANK() OVER `w_0` as `r`
|
|
from t
|
|
WINDOW `w_0` as ( ORDER BY `b` DESC)
|
|
) t0
|
|
where r in (1);
|
|
a r
|
|
1 1
|
|
select
|
|
a,
|
|
r
|
|
from (
|
|
select
|
|
a,
|
|
DENSE_RANK() OVER `w_0` as `r`
|
|
from t
|
|
WINDOW `w_0` as ( ORDER BY `b` DESC)
|
|
) t0
|
|
where a in (1,2);
|
|
a r
|
|
1 1
|
|
2 2
|
|
select
|
|
a,
|
|
r
|
|
from (
|
|
select
|
|
a,
|
|
DENSE_RANK() OVER `w_0` as `r`
|
|
from t
|
|
WINDOW `w_0` as ( ORDER BY `b` DESC)
|
|
) t0
|
|
where a in (1);
|
|
a r
|
|
1 1
|
|
select
|
|
a
|
|
from t
|
|
where a in (1,2);
|
|
a
|
|
1
|
|
2
|
|
select
|
|
a,
|
|
r
|
|
from (
|
|
select
|
|
a,
|
|
b as r
|
|
from t
|
|
) t0
|
|
where a in (1, 2);
|
|
a r
|
|
1 4
|
|
2 3
|
|
select
|
|
a,
|
|
r
|
|
from (
|
|
select
|
|
a,
|
|
b as r
|
|
from t
|
|
) t0
|
|
where a not in (1, 2);
|
|
a r
|
|
3 2
|
|
4 1
|
|
drop table if exists t;
|