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 ...
随机推荐
- Spark算子--flatMapValues
转载请标明出处http://www.cnblogs.com/haozhengfei/p/e7a46cecc65720997392516d553d9891.html flatMapValues--Tra ...
- github网站介绍、并使用git命令管理github(详细描述)
本章学习: 1)熟悉github网站 2)通过git命令远程管理github, 3)git命令使用ssh key密钥无需输入账号密码 1.首先我们来熟悉github网站 1.1 注册github 登录 ...
- WPF 实现新手指引功能 DEMO
需求 1.接口化.其他人实现接口就行 2.动态定位到visualTree中任意控件位置,即随意只显示任何部位 3.指示文本控件和箭头控件随意更改(位置,大小,高度,偏移等基本属性) 4.抽出主题 [d ...
- Tp框架查询分页显示与全部查询出来显示运行时间快慢有区别吗?
8:08:01 青春阳光 2017/4/7 8:08:01 大神在吗? Tp框架查询分页显示与全部查询出来显示运行时间快慢有区别吗? 青春阳光 2017/4/7 8:08:20 还有个问题,上传到pu ...
- Block 的使用时机
Block 一般是用来表示.简化一小段的程式码,它特别适合用来建立一些同步执行的程式片段.封装一些小型的工作或是用来做为某一个工作完成时的回传呼叫(callback) . 在新的iOS API中blo ...
- SQLite学习手册(实例代码<一>)
一.获取表的Schema信息: 1). 动态创建表. 2). 根据sqlite3提供的API,获取表字段的信息,如字段数量以及每个字段的类型. 3). 删除该表. ...
- Maven项目pom.xml 标签含义
project:pom.xml文件中的顶层元素: modelVersion:指明POM使用的对象模型的版本.这个值很少改动. groupId:指明创建项目的组织或者小组的唯一标识.GroupId是项目 ...
- Python实现一个简单的微信跳一跳辅助
1. 前言 微信的跳一跳相信大家都很熟悉了,而且现在各种外挂.辅助也是满天飞,反正本人的好友排行榜中已经是八九百都不足为奇了.某宝上一搜一堆结果,最低的居然只要3块多,想刷多少分就刷多少分,真是离谱 ...
- Web前端学习(4):显示图片、url与文件路径
本章主旨 介绍<img>标签及其基本属性:介绍URL和文件路径 在上一章中,我简单地介绍了HTML的一些基本标签及基本属性,例如,我们用<p>标签来标记文本段落,用<h1 ...
- junit断言总结
我们平时编写自己的测试类,如果没有断言,那么就没写测试的必要了. JUnit框架用一组assert方法封装了最常见的测试任务.这些assert方法可以极大地简化单元测试的编写. Assert类包含了一 ...