[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 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…
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 query should return 200 a…
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…
Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Email | +----+---------+ | 1 | a@b.com | | 2 | c@d.com | | 3 | a@b.com | +----+---------+ For example, your query should return the following for the abov…
Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to its previous (yesterday's) dates. +---------+------------------+------------------+ | Id(INT) | RecordDate(DATE) | Temperature(INT) | +---------+-----…
There is a table World +-----------------+------------+------------+--------------+---------------+ | name | continent | area | population | gdp | +-----------------+------------+------------+--------------+---------------+ | Afghanistan | Asia | 652…
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…
A pupil Tim gets homework to identify whether three line segments could possibly form a triangle. However, this assignment is very heavy because there are hundreds of records to calculate. Could you help Tim by writing a query to judge whether these…
Description Given three tables: salesperson, company, orders.Output all the names in the table salesperson, who didn’t have sales to company 'RED'. ExampleInput Table: salesperson +----------+------+--------+-----------------+-----------+ | sales_id…