sql 不熟悉点

个人学习总结,侵删。

1、查询表A中存在ID重复三次以上的记录,查询语句如下:

SELECT * from ( select *, count(user_id) as counts from articles GROUP BY user_id ) T where T.counts >= 3; 

2、查询平均成绩大于60分的同学的学号和平均成绩;

select stuId,avg(score) from Scores group by stuId having avg(score) >60;

https://www.cnblogs.com/zqm1/p/6559757.html

3、说出以下聚合数的含义:avg ,sum ,max ,min , count ,count(*)

点击打开链接

4、随机获取10条数据的方法

SELECT * FROM T_USER  ORDER BY  RAND() LIMIT 10

https://blog.csdn.net/lishimin1012/article/details/46516187

5、说明:显示文章、提交人和最后回复时间

select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where table.title=a.title) b


猜你喜欢

转载自blog.csdn.net/mysevenyear/article/details/80536538