SELECT * FROM( SELECT id,name,counts,createDate,row_number() OVER(partition BY name ORDER BY createDate DESC) rowno FROM testTable ) t WHERE t.rrowno <=1