文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

leetcode SQL题目

2023-08-30 11:00

关注
SELECT firstName,lastName,city,state FROM Person LEFT JOIN Address ON Person.PersonId=Address.PersonId
SELECTIFNULL((SELECT DISTINCT salary FROM Employee Order by salary desc LIMIT 1,1),null) AS SecondHighestSalary
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INTBEGINSET N:=N-1;  RETURN (      # Write your MySQL query statement below.      SELECT IFNULL((SELECT DISTINCT salary FROM Employee ORDER BY salary DESC LIMIT N,1),NULL)   );END
SELECT score, (SELECT count(DISTINCT score)+1 FROM Scores S2 Where S2.score>Scores.score) AS 'rank' FROM Scores ORDER BY score DESC
SELECT DISTINCT l1.num AS 'ConsecutiveNums' FROM Logs l1,Logs l2,Logs l3 WHERE l1.id=l2.id-1 AND l2.id=l3.id-1 AND l1.num=l2.num AND l2.num=l3.num
SELECT e.name AS Employee FROM Employee e,Employee e2 WHERE e2.id=e.managerId AND e.salary > e2.salary
SELECT DISTINCT p1.email AS Email FROM Person p1,Person p2 WHERE p1.email=p2.email AND p1.id !=p2.id
SELECT name AS Customers FROM Customers WHERE id NOT IN (SELECT DISTINCT customerId FROM Orders)
SELECT Department.name AS Department,e.name AS Employee,e.salary AS Salary FROM Department,Employee e WHERE Department.id=e.departmentId AND e.salary >= ALL(SELECT salary FROM Employee e2 WHERE e.departmentId = e2.departmentId)
SELECT Department.name AS Department, e.name AS Employee,e.salary AS Salary FROM Employee e,Department WHERE e.departmentId=Department.id AND(SELECT COUNT(Distinct e2.salary) FROM Employee e2 WHERE e2.departmentId=e.departmentId AND e2.salary>e.salary)<3 ORDER BY e.departmentId ASC
DELETE p2 FROM Person p1,Person p2 WHERE p1.email=p2.email AND p1.id<p2.id
SELECT w2.id AS Id FROM Weather w1,Weather w2 WHERE DATEDIFF(w2.recordDate,w1.recordDate)=1 AND w1.Temperature < w2.Temperature

DATEDIFF()函数用于计算两个日期的天数差

SELECT player_id,MIN(event_date) AS first_login FROM Activity GROUP BY player_id
SELECT ROUND((SELECT COUNT(DISTINCT b.player_id) FROM Activity b WHERE (b.player_id,b.event_date) IN(SELECT a.player_id,DATE(MIN(a.event_date)+INTERVAL 1 DAY) FROM Activity a GROUP BY a.player_id))/(SELECT COUNT(DISTINCT player_id) FROM Activity),2) AS fraction

来源地址:https://blog.csdn.net/qq_43716830/article/details/132453976

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-人工智能
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯