DISTINCT name,MAX(score) AS score,MIN(time) AS Time
FROM tb_data
GROUP BY name
ORDER BY time DESC
--DISTINCT()去重
--MAX(score)取得最高成绩
--MIN(time)取得最短用时
删除数据表中重复数据,可以使用以下SQL语句:mysql>CREATE TABLE tmp SELECT no, name, sex FROM student GROUP BY (no, sex)
mysql>DROP TABLE student
mysql>ALTER TABLE tmp RENAME TO student
也可以在数据表中添加INDEX(索引)和 PRIMAY KEY(主键)来删除表中的重复记录,方法如下:
mysql>ALTER IGNORE TABLE student
->ADD PRIMARY KEY (no)
order by cont ->order by count(*)select count(*) as cont,ctt_id from tmp GROUP BY ctt_id order by count(*) desc limit 0,20
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)