【leetcode】SQL相关的题目

最近在学MYSQL,慢慢更新吧

推荐好书:SQL必知必会。靠这本书入了个门

以下均为MYSQL方式提交

Duplicate Emails

select Email from Person
group by email
having count(*) >1

Employees Earning More Than Their Managers

select E1.name as Employee
from Employee as E1,Employee as E2
where E1.ManagerID=E2.Id and E1.Salary>E2.Salary

Combine Two Tables

select FirstName,LastName,City,State from Person
left join Address on Person.PersonId=Address.PersonId;

Customers Who Never Order

select name as Customers from Customers C
where C.Id not in (select CustomerID from Orders);
时间: 2024-10-24 21:26:18

【leetcode】SQL相关的题目的相关文章

LeetCode SQL题目(第一弹)

LeetCode SQL题目 注意:Leetcode上的SQL编程题都提供了数据表的架构程序,只需要将它贴入本地数据库即可调试自己编写的程序 不管是MS-SQL Server还是MySQL都需要登陆才能使用,我没有使用SSMS 或Workbench,而是直接使用sqlcmd,解决登陆问题可以参考这个链接(http://www.cnblogs.com/skynothing/archive/2010/08/26/1809125.html)感谢这位博主的帮助. 181. Employees Earni

[LeetCode][SQL]Nth Highest Salary

Nth Highest Salary Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+ For example, given the above Employee table, the nth highe

sql相关操作

1.两个不同数据库对应字段相应操作 //操作模版:insert into data2.table2(字段1,字段2,字段) select 字段j,字段k,字段m from data1.table1举例:insert into Hospitals.dbo.Deparments(DepartmentName) select distinct(Departments)from NanFan.dbo.UserInfo where Unit='南方医院'//更新update Hospitals.dbo.U

使用ttXactAdmin、ttSQLCmdCacheInfo、ttSQLCmdQueryPlan获取SQL相关详细信息[TimesTen运维]

使用ttXactAdmin.ttSQLCmdCacheInfo.ttSQLCmdQueryPlan获取SQL相关详细信息,适合于tt11以上版本. $ ttversion TimesTen Release 11.2.2.4.3 (64 bit Linux/x86_64) (tt1122:53396) 2013-02-09T17:19:52Z Instance admin: timesten Instance home directory: /TimesTen/tt1122 Group owner

使用ttXactAdmin、ttSQLCmdCacheInfo、ttSQLCmdQueryPlan获取SQL相关具体信息[TimesTen运维]

使用ttXactAdmin.ttSQLCmdCacheInfo.ttSQLCmdQueryPlan获取SQL相关具体信息,适合于tt11以上版本号. $ ttversion TimesTen Release 11.2.2.4.3 (64 bit Linux/x86_64) (tt1122:53396) 2013-02-09T17:19:52Z Instance admin: timesten Instance home directory: /TimesTen/tt1122 Group owne

Leetcode回溯相关题目Python实现

1.46题,全排列 https://leetcode-cn.com/problems/permutations/ class Solution(object): def permute(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ n = len(nums) results = [] def backtrack(first = 0): if first ==

[LeetCode][SQL]Second Highest Salary

https://leetcode.com/problems/second-highest-salary/ Second Highest Salary Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+

SQL查询练习题目

设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一)~表(四)所示,数据如表1-2的表(一)~表(四)所示.用SQL语句创建四个表并完成相关题目. 表1-1数据库的表结构 表(一)Student (学生表) 属性名 数据类型 可否为空 含 义 Sno Char(3) 否 学号(主码) Sname Char(8) 否 学生姓名 Ssex Char(2) 否 学生性别 Sbirthday

leetcode 锁掉的题目清单

也刷leetcode, 先把锁掉的题目留备份好了: 156 Binary Tree Upside Down  [1] Problem: Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty, flip it upside down and turn it into a tre