随笔分类 -  (Mysql)

摘要:820. 单词的压缩编码 字典树,将字符串首先按照长度进行排序,然后将字符串倒序插入到字典树中,在插入的时候加一个判断语句, 如果是ch[p][str[i] - 'a'] == 0的话,就代表需要在字典树上插入新的值,所以在这里可以打一个标志位 class Solution { public: in 阅读全文
posted @ 2020-03-28 13:30 Let_Life_Stop 阅读(224) 评论(0) 推荐(0)
摘要:601. 体育馆的人流量 暴力搜索条件 一开始不知道怎么去重,然后看了一眼评论区就行白了,直接 select s1.* 就可以对全表的数据进行去重 # Write your MySQL query statement below select distinct s1.* from stadium s 阅读全文
posted @ 2020-03-27 11:45 Let_Life_Stop 阅读(150) 评论(0) 推荐(0)
摘要:262. 行程和用户 # Write your MySQL query statement below select t.Request_at as Day, round(count(if(t.Status != 'completed', status, null))/count(status), 阅读全文
posted @ 2020-03-24 19:08 Let_Life_Stop 阅读(164) 评论(0) 推荐(0)
摘要:184. 部门工资最高的员工 需要注意的几个点,inner join可以缩减成join,取的是两个表的交集 in关键词,找的是当前所要找的数值是否在指定的范围之中 # Write your MySQL query statement below select d.Name as Department 阅读全文
posted @ 2020-03-18 12:20 Let_Life_Stop 阅读(127) 评论(0) 推荐(0)
摘要:https://leetcode-cn.com/problems/rank-scores/ 178. 分数排名 select s1.Score, count(distinct s2.Score) as Rank from scores as s1, scores as s2 where s1.Sco 阅读全文
posted @ 2020-03-13 13:46 Let_Life_Stop 阅读(240) 评论(0) 推荐(0)
摘要:编写一个 SQL 查询,获取 Employee 表中第二高的薪水(Salary) 。 + + +| Id | Salary |+ + +| 1 | 100 || 2 | 200 || 3 | 300 |+ + +例如上述 Employee 表,SQL查询应该返回 200 作为第二高的薪水。如果不存在 阅读全文
posted @ 2019-09-28 15:38 Let_Life_Stop 阅读(258) 评论(0) 推荐(0)
摘要:1) 具体思路:学号对应姓名,课程编号对应课程名,然后判断Sc表中学号对应的姓名,dsec调整降序输出,distinct去重/group by 去重 select distinct Sname from S,C,SC where S.Sno = SC.Sno and C.Cno = SC.Cno and C.Cname = 's数据库' order by Sname desc; 或者通过group 阅读全文
posted @ 2019-09-10 21:32 Let_Life_Stop 阅读(205) 评论(0) 推荐(0)