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 ...
随机推荐
- Linux系统上安装JDK和Tomcat服务器
一.安装JDK 1.查看当前Linux系统是否已经安装java 输入命令: rpm -qa | grep java 2.卸载两个openJDK 输入命令:rpm -e --nodeps 3.上传j ...
- Jfinal——实践出真知
什么是Jfinal? JFinal 是基于 Java 语言的极速 WEB + ORM 框架,其核心设计目标是开发迅速.代码量少.学习简单.功能强大.轻量级.易扩展.Restful.在拥有Java语言所 ...
- hbase性能优化总结
hbase性能优化总结 1. 表的设计 1.1 Pre-Creating Regions 默认情况下,在创建HBase表的时候会自动创建一个region分区,当导入数据的时候,所有的HBase客户端都 ...
- 虚拟主机导入MySQL出现Unknown character set: ‘utf8mb4’
http://www.lmlblog.com/14.html 前几天进行网站搬家,MySQL导入数据的时候,出现以下错误(没有定义的编码集utf8mb4): SQL 查询: ; MySQL 返回:文档 ...
- 显示/隐藏Mac隐藏文件
显示Mac隐藏文件的命令:defaults write com.apple.finder AppleShowAllFiles -bool true 隐藏Mac隐藏文件的命令:defaults writ ...
- SVN的安装和配置
SVN为程序开发团队常用的代码管理,版本控制软件:下面我们来介绍TortoiseSVN的安装,和其服务器的搭建:(下面为windows 64位系统下的搭建) 闲来无事,就在本地搭建了一个SVN环境,网 ...
- RequireJS(一)
RequireJS: RequireJS中文网:http://www.requirejs.cn/ 解决HTML引入大量js文件导致的问题: 首先是加载的时候,浏览器会停止网页渲染,加载文件越多,网页失 ...
- Python+Selenium安装及环境配置
一.Python安装 Window系统下,python的安装很简单.访问python.org/download,下载最新版本,安装过程与其他windows软件类似.记得下载后设置path环境变量,然后 ...
- Performance Testing 入门小结
从事软件测试两年多了,一直在做功能测试.2016年计划学习Performance.今天,先把之前听过的同事session以及自己查阅的资料小结一下. 一.什么是性能测试 首先来说一下软件的性能是什么. ...
- css超出内容以省略号显示
控制只显示2行,并以省略号结束 text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-or ...