create or replace table t(id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,part bigint(20) NOT NULL,ts bigint(20) DEFAULT NULL, key idx(part) );
set @seq:=1; insert into t select null ,1 , @seq;
insert into t select null ,1 , @seq:=@seq+1 from t;
insert into t select null ,1 , @seq:=@seq+1 from t;
insert into t select null ,1 , @seq:=@seq+1 from t;
insert into t select null ,1 , @seq:=@seq+1 from t;
insert into t select null ,1 , @seq:=@seq+1 from t;
insert into t select null ,1 , @seq:=@seq+1 from t;
insert into t select null ,1 , @seq:=@seq+1 from t;
insert into t select null ,1 , @seq:=@seq+1 from t;
insert into t select null ,1 , @seq:=@seq+1 from t;
insert into t select null ,1 , @seq:=@seq+1 from t;
insert into t select null ,1 , @seq:=@seq+1 from t;
insert into t select null ,1 , @seq:=@seq+1 from t;
insert into t select null ,1 , @seq:=@seq+1 from t;
insert into t select null ,1 , @seq:=@seq+1 from t;
insert into t select null ,1 , @seq:=@seq+1 from t;
insert into t select null ,1 , @seq:=@seq+1 from t;
insert into t select null ,1 , @seq:=@seq+1 from t;
insert into t select null ,1 , @seq:=@seq+1 from t;
select part , MAX(ts) OVER (PARTITION BY part) AS ts_max FROM t where part=1;