[LeetCode] 627. Swap Salary_Easy tag: SQL
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 |
Code
UPDATE Salary SET sex = IF(sex = 'f', 'm', 'f')
也就是说if sex == 'f' , sex = 'm'
else: sex = 'f'
[LeetCode] 627. Swap Salary_Easy tag: SQL的更多相关文章
- [LeetCode] 176. Second Highest Salary_Easy tag: SQL
Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | S ...
- 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 v ...
- [LeetCode] 182. Duplicate Emails_Easy tag: SQL
Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...
- [LeetCode] 197. Rising Temperature_Easy tag: SQL
Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to ...
- [LeetCode] 595. Big Countries_Easy tag: SQL
There is a table World +-----------------+------------+------------+--------------+---------------+ ...
- 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 ...
- [LeetCode] 610. Triangle Judgement_Easy tag: SQL
A pupil Tim gets homework to identify whether three line segments could possibly form a triangle. Ho ...
- [LeetCode] 607. Sales Person_Easy tag: SQL
Description Given three tables: salesperson, company, orders.Output all the names in the table sales ...
随机推荐
- jQuery属性操作(三)
在阅读attr.remove方法时,看到一些对浏览器兼容性做处理的hooks.接下来看一下这些hooks都做了哪些兼容性处理 1.attrHooks.主要处理IE6-9 input的type属性无法写 ...
- c++ istream转换为std::string
std::istreambuf_iterator<char> eos; std::string s(std::istreambuf_iterator<char>(stream) ...
- MongoDB3.4版本配置详解
重要配置参数讲解如下 processManagement: fork: <true | false> 描述:是否以fork模式运行mongod/mongos进程,默认为false. pid ...
- CF 672D Robin Hood(二分答案)
D. Robin Hood time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Junit4单元测试报错
转载博客:http://www.cnblogs.com/sxdcgaq8080/p/5649819.html 今天是用JUnit测试一段代码,报错method initializationerror ...
- 源码包安装Python3.6
1,安装Python3.6的依赖包 # yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel r ...
- jenkins定时任务未生效解决
近期在配置jenkins定时任务时,发现未生效,并没有按时触发任务 解决思路: 1.先查看下我们的定时任务有没有选择正确,如下说明: Poll SCM:定时检查源码变更,如果有更新就checkout最 ...
- Jmeter TCP取样器配置及发送图解
最近在通过Jmeter测试TCP发送请求时,遇到相关问题,现记录 查看管方文档,TCP发送有三种启用方式: TCPClientImpl:文本数据,默认为这种 BinaryTCPClientImpl:传 ...
- spring boot 部署
指定运行的内存 java -Xms10m -Xmx200m -jar xxx.jar spring boot 打包成war包: 让 SpringbootApplication 类继承 SpringBo ...
- jquery 设置style:display 其实很方便的哦
("#id").css('display','none'); $("#id").css('display','block'); 或 $("#id&qu ...