- 博客(21)
- 收藏
- 关注
原创 Oracle-游标循环插入数据
遇到一个需求统计历史每个月底的数据插入到表中,查询了资料发现使用游标会很方便,记录一下解决思路先查出每个月月底的日期作为条件select to_char(lastday, 'yyyy-mm-dd') lastday from (select last_day(add_months(to_date('201408', 'yyyymm'), level)) lastday ...
2018-09-25 16:08:16 7111
原创 LeetCode数据库-627. 交换工资
update salary set sex=(case when sex="m" then "f" else "m" end
2018-09-14 14:42:28 228
原创 LeetCode数据库-626. 换座位
如果总数为偶数直接替换相邻的同学,如果是奇数最大的id同学位置不变。用sql表达为select * from (select b.id-1 id,b.student student FROMseat a,seat bwhere a.id+1=b.idand mod(b.id,2) = 0UNIONselect a.id+1 id,a.student student FRO...
2018-09-14 14:39:44 296
原创 LeetCode数据库-620. 有趣的电影
条件:!=boring and mod(id,2)=1(计算奇数)select * from cinemawhere description !="boring"and mod(id,2) = 1order by rating desc
2018-09-13 11:05:48 326
原创 Leetc数据库-601. 体育馆的人流量
这里我直接列出来了全部的情况查出来的select distinct a.*from stadium a,stadium b,stadium cwhere a.people>=100 and b.people>=100 and c.people>=100and ((a.id+1=b.id and b.id+1=c.id)or/*abc*/(a.id+1=b.i...
2018-09-13 11:02:11 742
原创 LeetCode数据库-596. 超过5名学生的课
查找每个课程的去重后的学生数量大于5select a.class "class" from(select count(distinct(student)) num,classfrom coursesgroup by class)a where a.num>=5
2018-09-13 10:58:47 224
原创 LeetCode数据库-595. 大的国家
这个直接做数据比较就可以得出select name "name",population "population",area "area"from Worldwhere area > 3000000or population >25000000
2018-09-13 10:57:11 236
原创 LeetCode数据库-262. 行程和用户
关联两张表,一个是查询10.1-10.3非禁止用户全部的数据,一个是查询10.1-10.3非禁止用户取消的数据,然后再计算取消率select b.Day "Day", convert(IFNULL(num1/num2,0),decimal(10,2)) AS 'Cancellation Rate'from(select request_at "Day",count(id) ...
2018-09-13 10:55:36 344
原创 Leetc数据库-197. 上升的温度
给定一个 Weather 表,编写一个 SQL 查询,来查找与之前(昨天的)日期相比温度更高的所有日期的 Id。 例如,根据上述给定的 Weather 表格,返回如下 Id: 关联两个Weqther,date1比date2大一天且temperature1>temperature sql如下:select a.id "Id"from weather a,weather b...
2018-09-13 10:50:40 418
原创 LeetCode数据库-196. 删除重复的电子邮箱
编写一个 SQL 查询,来删除 Person 表中所有重复的电子邮箱,重复的邮箱里只保留 Id 最小 的那个。 例如,在运行你的查询语句之后,上面的 Person 表应返回以下几行: 关联Person p1,Person p2,条件p1.Email=p2.Email,p1.id>p2.iddelete p1 from person p1,person p2 WHERE p1...
2018-09-13 10:45:34 627
原创 Leet数据库-185. 部门工资前三高的员工
Employee 表包含所有员工信息,每个员工有其对应的 Id, salary 和 department Id 。 Department 表包含公司所有部门的信息。 编写一个 SQL 查询,找出每个部门工资前三高的员工。例如,根据上述给定的表格,查询结果应返回: 思路是查询Employee a,Employee b 而且a.salary小于b.salary,a.departmen...
2018-09-13 10:37:40 782
原创 Leet数据库184. 部门工资最高的员工
Employee 表包含所有员工信息,每个员工有其对应的 Id, salary 和 department Id。+----+-------+--------+--------------+| Id | Name | Salary | DepartmentId |+----+-------+--------+--------------+| 1 | Joe | 70000 |...
2018-09-13 10:02:41 296
原创 LeetCode数据库-183. 从不订购的客户
某网站包含两个表,Customers 表和 Orders 表。编写一个 SQL 查询,找出所有从不订购任何东西的客户。Customers 表:+----+-------+| Id | Name |+----+-------+| 1 | Joe || 2 | Henry || 3 | Sam || 4 | Max |+----+-------+Or...
2018-09-13 09:50:35 193
原创 LeetCode数据库-182. 查找重复的电子邮箱
编写一个 SQL 查询,查找 Person 表中所有重复的电子邮箱。+----+---------+| Id | Email |+----+---------+| 1 | a@b.com || 2 | c@d.com || 3 | a@b.com |+----+---------+根据以上输入,你的查询应返回以下结果:+---------+| Email ...
2018-09-13 09:45:51 334
原创 LeetCode数据库-181. 超过经理收入的员工
Employee 表包含所有员工,他们的经理也属于员工。每个员工都有一个 Id,此外还有一列对应员工的经理的 Id。+----+-------+--------+-----------+| Id | Name | Salary | ManagerId |+----+-------+--------+-----------+| 1 | Joe | 70000 | 3 ...
2018-09-07 10:00:16 455
原创 LeetCode数据库-180. 连续出现的数字
编写一个 SQL 查询,查找所有至少连续出现三次的数字。+----+-----+| Id | Num |+----+-----+| 1 | 1 || 2 | 1 || 3 | 1 || 4 | 2 || 5 | 1 || 6 | 2 || 7 | 2 |+----+-----+例如,给定上面的 Logs 表, 1 是唯一连...
2018-09-07 09:53:04 418
原创 LeetCode数据库-178. 分数排名
编写一个 SQL 查询来实现分数排名。如果两个分数相同,则两个分数排名(Rank)相同。请注意,平分后的下一个名次应该是下一个连续的整数值。换句话说,名次之间不应该有“间隔”。+----+-------+| Id | Score |+----+-------+| 1 | 3.50 || 2 | 3.65 || 3 | 4.00 || 4 | 3.85 || 5...
2018-09-06 17:46:04 1247
原创 LeetCode数据库-177. 第N高的薪水
编写一个 SQL 查询,获取 Employee 表中第 n 高的薪水(Salary)。+----+--------+| Id | Salary |+----+--------+| 1 | 100 || 2 | 200 || 3 | 300 |+----+--------+例如上述 Employee 表,n = 2 时,应返回第二高的薪水 200。如果...
2018-09-06 17:04:26 516
原创 LeetCode数据库-176. 第二高的薪水
编写一个 SQL 查询,获取 Employee 表中第二高的薪水(Salary) 。+----+--------+| Id | Salary |+----+--------+| 1 | 100 || 2 | 200 || 3 | 300 |+----+--------+例如上述 Employee 表,SQL查询应该返回 200 作为第二高的薪水。如果...
2018-09-06 16:58:31 214
原创 LeetCode数据库-175. 组合两个表
表1: Person+-------------+---------+| 列名 | 类型 |+-------------+---------+| PersonId | int || FirstName | varchar || LastName | varchar |+-------------+---------+Person...
2018-09-06 16:46:15 269
计算机二级2021年office真题教程资料Excel减免税政策的任务,订单任务,分数段统计
2023-11-13
计算机二级2021年office真题教程资料Excel减免税政策的任务,订单任务,分数段统计
2023-11-13
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人