select a.* from 表名 a,(select userid,max(createtime) createtime from 表名 group by userid) bwhere a.userid=b.userid and a.createtime=b.createtime
表名自行替换一下