Skip to content

Commit

Permalink
Q627 added.
Browse files Browse the repository at this point in the history
  • Loading branch information
isinsuarici committed Mar 18, 2023
1 parent a81a88b commit 0821ae7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions SQL/Q627.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--Table: Salary

--+-------------+----------+
--| Column Name | Type |
--+-------------+----------+
--| id | int |
--| name | varchar |
--| sex | ENUM |
--| salary | int |
--+-------------+----------+
--id is the primary key for this table.
--The sex column is ENUM value of type ('m', 'f').
--The table contains information about an employee.


--Write an SQL query to swap all 'f' and 'm' values (i.e., change all 'f' values to 'm' and vice versa) with a single update statement and --no intermediate temporary tables.

--Note that you must write a single update statement, do not write any select statement for this problem.

UPDATE salary
SET sex = CASE sex
WHEN 'm' THEN 'f'
ELSE 'm'
END;

0 comments on commit 0821ae7

Please sign in to comment.