LeetCode - 627. Swap Salary】的更多相关文章

Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update query and no intermediate temp table. For example: | id | name | sex | sala…
https://leetcode.com/problems/swap-salary/description/ 用  set keyWord = Case depentedWord when haha then baba else lala end 最后需要end # Write your MySQL query statement below update salary set sex = case sex when 'm' then 'f' else 'm' end;…
题目标签: 题目给了我们一个 工资表格,让我们把 男女性别对换. 这里可以利用IF, IF(condition, value_if_true, value_if_false). Java Solution: Runtime:  135 ms, faster than 94.04% Memory Usage: N/A 完成日期:07/02/2019 关键点:IF(condition, value_if_true, value_if_false) # Write your MySQL query s…
627. Swap Salary SQL Schema Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update query and no intermediate temp table. For examp…
Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update query and no intermediate temp table. For example: | id | name | sex | sala…
MySQL的IF既可以作为表达式用,也可在存储过程中作为流程控制语句使用,如下是做为表达式使用: IF表达式 IF(expr1,expr2,expr3) 如果 expr1 是TRUE (expr1 <> 0 and expr1 <> NULL),则 IF()的返回值为expr2; 否则返回值则为 expr3.IF() 的返回值为数字值或字符串值,具体情况视其所在语境而定. SELECT IF(sva=1,"男","女") AS s FROM…
SQL架构 create table ), sex ), salary int) Truncate table salary insert into salary (id, name, sex, salary) values (') insert into salary (id, name, sex, salary) values (') insert into salary (id, name, sex, salary) values (') insert into salary (id, n…
The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id. +----+-------+--------+--------------+ | Id | Name | Salary | DepartmentId | +----+-------+--------+--------------+ | 1 | Jo…
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 highest salary where n =…
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 Employee table, the second highest salary is …