SQL

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 statement and no intermediate temp table.

Note that you must write a single update statement, DO NOT write any select statement for this problem.

Logic: Use Set statement and If() function would do the trick

LINK

--

--

--

My homepage to record my thought processes for solving SQL and Algorithm questions

Recommended from Medium

Build a Real-time Market Monitor with Bloomberg, xbbg, Redis, FastAPI, WebSocket and ag-Grid

🎊 THE FEATUREPRENEUR 🎊

How Technology Is Changing How We Treat Systeme IO review

Move Vagrant virtual machine, keep everything (database, virtual hosts etc..)

Top 15 packages one should not miss — Flutter💙

Upcoming Conferences for Developers in February

YubiKey for SSH

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jen-Li Chen

Jen-Li Chen

In love with telling stories with data

More from Medium

How to sort result set in custom order in SQL?

LeetCode SQL| 196. Delete Duplicate Emails

Seven Join Techniques in SQL

SQL Database