习题资料:
1. Mysql经典练习题50题
1.习题一

select user_id ,count(distinct(artcle_id)) as count
from article
where view_time=”2021-01-13”
group by user_id
having count>100
order by count desc
limit 10;
2.排行表
解法一:
SELECTS1.score 'Score',COUNT( DISTINCT S2.score ) 'Rank'FROMScores S1INNER JOIN Scores S2ON S1.score <= S2.scoreGROUP BYS1.id, S1.scoreORDER BYS1.score DESC;
先观察这条sql的执行结果!
select *
FROM Scores S1
INNER JOIN Scores S2
ON S1.score <= S2.score
ORDER BY S1.id, S1.score
按S1.id, S1.score进行分组,这样可以保证相同分数也不会分到一组,因为id肯定是不一样的(其实只按id分组效果也一样!)
