-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a81a88b
commit 0821ae7
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |