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 | salary |
|----|------|-----|--------|
| 1 | A | m | 2500 |
| 2 | B | f | 1500 |
| 3 | C | m | 5500 |
| 4 | D | f | 500 |
After running your query, the above salary table should have the following rows:
| id | name | sex | salary |
|----|------|-----|--------|
| 1 | A | f | 2500 |
| 2 | B | m | 1500 |
| 3 | C | f | 5500 |
| 4 | D | m | 500 |
# Write your MySQL query statement below
update salary set sex= case sex when 'f' then 'm' else 'f' end
LeetCode - 627. Swap Salary的更多相关文章
- leetcode 627. Swap Salary 数据库带判断的更新操作
https://leetcode.com/problems/swap-salary/description/ 用 set keyWord = Case depentedWord when haha ...
- LeetCode 627. Swap Salary (交换工资)
题目标签: 题目给了我们一个 工资表格,让我们把 男女性别对换. 这里可以利用IF, IF(condition, value_if_true, value_if_false). Java Soluti ...
- 627. Swap Salary
627. Swap Salary SQL Schema Given a table salary, such as the one below, that has m=male and f=femal ...
- [LeetCode] 627. Swap Salary_Easy tag: SQL
Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m v ...
- SQL语句中IF的简单使用 - 关联leetcode 627.交换工资
MySQL的IF既可以作为表达式用,也可在存储过程中作为流程控制语句使用,如下是做为表达式使用: IF表达式 IF(expr1,expr2,expr3) 如果 expr1 是TRUE (expr1 & ...
- [SQL]LeetCode627. 交换工资 | Swap Salary
SQL架构 create table ), sex ), salary int) Truncate table salary insert into salary (id, name, sex, sa ...
- [LeetCode] Department Highest Salary 系里最高薪水
The Employee table holds all employees. Every employee has an Id, a salary, and there is also a colu ...
- [LeetCode] Nth Highest Salary 第N高薪水
Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Sala ...
- [LeetCode] Second Highest Salary 第二高薪水
Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | S ...
随机推荐
- ObjectiveC 深浅拷贝学习
在ObjC中,什么是深浅拷贝? 深浅拷贝分别指深拷贝和浅拷贝,即mutableCopy和copy方法. copy复制一个不可变对象,而mutableCopy复制一个mutable可变对象. 什么时候用 ...
- 【开发技术】Xcode3与xcode4.2模板对比(Xcode4.2开发之一些变化)
Xcode3中IOS下的Application的模板如下: Navigation_Based Application OpenGL ES Application Tab Bar Application ...
- 【开发技术】java异常的捕获与抛出原则
在可能会出现exception的地方,要使用try-catch或者throws或者两者都要.我的判断依据是:如果对可能出现的exception不想被外部(方法的调用者)知道,就在方法内部try-cat ...
- Asp.net Core 跨域配置
一般情况WebApi都是跨域请求,没有设置跨域一般会报以下错误 No 'Access-Control-Allow-Origin' header is present on the requested ...
- [one day one question] Vue单页面应用如何保证F5强刷不清空数据
问题描述: Vue单页面用按F5强刷,数据就恢复初始了,这怎么破? 解决方案: store.subscribe((mutation, state) => { sessionStorage.set ...
- scipy.optimize.minimize 解决实际问题
接上博客问题http://www.cnblogs.com/shizhenqiang/p/8274806.html # coding=utf-8 from scipy import optimize i ...
- Django 模版中如何对主菜单进行选中?
问题描叙: 在实际模版中,返回的页面我们想要主菜单保持一种状态,这个主菜单进去的子页面,都需要保持主菜单选择状态 例如 主菜单是 课程, 下面展现的章节和视频页面时候, 课程这个主菜单在展现这个菜单下 ...
- sitemesh网页布局
看项目时发现对应页面下找不到侧栏部分代码,仔细观察后发现页面引入了sitemesh标签,查了下资料原来是页面用了sitemesh框架解!耦!了! 以前多个模块包含相同模块时总是include jsp文 ...
- Linux实践篇--crontab定时任务
原文出处:http://www.cnblogs.com/tracy/archive/2011/12/27/2303788.html.感谢作者的无私分享 一. Crontab 介绍 ...
- Servlet--HttpUtils类
定义 public class HttpUtils 收集 HTTP Servlet 使用的静态的有效的方法. 方法 1.getRequestURL public static StringBuffer ...