摘要:https://leetcode.com/problems/not-boring-movies/description/ 不管题目简不简单,现在先熟悉语法。 直接用where语句判断即可,判断奇偶可以用 % 还有用 & 也行
阅读全文
摘要:https://leetcode.com/problems/swap-salary/description/ 用 set keyWord = Case depentedWord when haha then baba else lala end 最后需要end # Write your MySQL
阅读全文
摘要:https://leetcode.com/problems/duplicate-emails/description/ 首先sql的执行顺序是 from-->where-->group by >having-->select-->order by 所以用了group后,用where判断是错误的 ht
阅读全文
摘要:https://leetcode.com/problems/employees-earning-more-than-their-managers/description/ 老师上课没分析这些的复杂度,我大概认为子查询要O(n^2) 一开始,直接用了子查询,2400ms.... # Write you
阅读全文
摘要:https://leetcode.com/problems/second-highest-salary/description/ 题目要求输出第二大的成绩。 首先可以想到去重,然后排序,相当于输出第二个成绩。 这个用limit a offset b表示,从第b项开始,选出a个,下标从0开始 然后,如
阅读全文
摘要:https://leetcode.com/problemset/database/ ACM退役,刚好要学sql,一定要刷题才行,leetcode吧。 这一题,说了两个表,一个左一个右吧,左边的personId是唯一的,但是右边的PersonId是不唯一的,所以不去重。 然后,总结下各种join的用法
阅读全文