sql
dogndaxiaodong
东北大学软件学院大二学生
展开
-
leetcode-游戏玩法分析
# Write your MySQL query statement below select player_id,min(event_date) as first_login from activity a group by player_id ; 这道题我明白了,group by 之后可以使用各种聚合函数例如min,max求值! ...原创 2019-12-31 20:15:52 · 443 阅读 · 0 评论 -
leetcode-文章浏览
# Write your MySQL query statement below select distinct author_id as id from Views where author_id = viewer_id order by author_id 很简单的一道题....原创 2019-12-31 19:51:15 · 150 阅读 · 0 评论 -
leetcode-每位学生的最高成绩
# Write your MySQL query statement below select e.student_id,(select course_id from Enrollments en where en.student_id=e.student_id and en.grade = max(e.grade) order by course_id limit 1) as course_i...原创 2019-12-31 19:34:04 · 213 阅读 · 0 评论 -
leetcode-Average Selling Price
# Write your MySQL query statement below select p.product_id,round(sum(p.price*u.units)/sum(u.units),2) as average_price from Prices p join UnitsSold u on p.product_id = u.product_id where u.purchas...原创 2019-12-29 14:55:38 · 477 阅读 · 0 评论 -
leetcode-分数排名
# Write your MySQL query statement below select Score , (select count(distinct Score) from Scores where Score>=s.Score) as Rank from Scores s order by Score desc 从这道题可以看出,可以广泛的思考利用子查询求解局部。 还有就是子...原创 2019-12-29 14:44:44 · 701 阅读 · 0 评论 -
leetcode-组合两个表
# Write your MySQL query statement below select p.FirstName,p.LastName,a.City,a.State from Person p left join Address a on p.PersonId=a.PersonId 因为题目中要求如果address表中没有对应数据也需要显示。所以使用left join,意思是左表中每一...原创 2019-12-25 21:56:28 · 82 阅读 · 0 评论 -
leetcode-换座位
# Write your MySQL query statement belo select (case when mod(id,2) = 1 and id != (select count(*) from seat) then id+1 when mod(id,2) = 0 then id-1 when mod(id,2) = 1 and id=(select coun...原创 2019-12-25 21:52:51 · 181 阅读 · 0 评论