USE tpch1; drop table if exists t; create table t(a bigint, b varchar(10)) engine=columnstore; insert into t values (1, 'hi'); insert into t values (1, 'hello'); insert into t values (2, 'bye'); insert into t values (2, 'good night'); select t.*, row_number() over (partition by a order by b) as rnum from t; a b rnum 1 hello 1 1 hi 2 2 bye 1 2 good night 2 drop view if exists v; create view v as select * from t; select v.*, row_number() over (partition by a order by b) as rnum from v; a b rnum 1 hello 1 1 hi 2 2 bye 1 2 good night 2 select v.*, min(a) over (partition by a order by b) as rnum from v; a b rnum 1 hello 1 1 hi 1 2 bye 2 2 good night 2 select rank() over(order by a) from v; rank() over(order by a) 1 1 3 3 drop table t; drop view v;