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…
SQL查询练习一(From LeetCode) 1 select name,population,area 2 from World 3 where area > 3000000 or population > 25000000   3.判断是否是三角形(E) 思路,使用case when进行搭配,使用三角形定义进行判断x+y>z,x+z>y,y+z>x 1 select x,y,z, 2 case 3 when x+y>z and y+z>x and x+z&g…
##题目1 626. 换座位 小美是一所中学的信息科技老师,她有一张 seat 座位表,平时用来储存学生名字和与他们相对应的座位 id. 其中纵列的 id 是连续递增的 小美想改变相邻俩学生的座位. 你能不能帮她写一个 SQL query 来输出小美想要的结果呢?   示例: +---------+---------+ | id | student | +---------+---------+ | 1 | Abbot | | 2 | Doris | | 3 | Emerson | | 4 |…
题目1 产品数据表: Products +---------------+---------+ | Column Name | Type | +---------------+---------+ | product_id | int | | new_price | int | | change_date | date | +---------------+---------+ 这张表的主键是 (product_id, change_date). 这张表的每一行分别记录了 某产品 在某个日期 更…
题目 1205. 每月交易II Transactions 记录表 +----------------+---------+ | Column Name | Type | +----------------+---------+ | id | int | | country | varchar | | state | enum | | amount | int | | trans_date | date | +----------------+---------+ id 是这个表的主键. 该表包含…
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId | int | | FirstName | varchar | | LastName | varchar | +-------------+---------+ PersonId is the primary key column for this table. Table: Address +--…
, NULL, salary) as `salary` from ( ,) tmp Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+ For example, given the above Emp…
题目1 Employee 表包含所有员工信息,每个员工有其对应的 Id, salary 和 department Id. +----+-------+--------+--------------+ | Id | Name | Salary | DepartmentId | +----+-------+--------+--------------+ | 1 | Joe | 70000 | 1 | | 2 | Henry | 80000 | 2 | | 3 | Sam | 60000 | 2 |…
# Write your MySQL query statement below SELECT a.Name FROM Employee AS a INNER JOIN Employee AS b ON a.ManagerId = b.Id WHERE a.Salary > b.Salary 让我来看看讨论区,并没有发现更好的…
https://leetcode.com/problems/duplicate-emails/description/ 首先sql的执行顺序是 from-->where-->group by--->having-->select-->order by 所以用了group后,用where判断是错误的 # Write your MySQL query statement below select distinct Email //这里不需要distinct,因为group后,相同…