In interviews for software developer roles SQL questions can sometimes come up. There is a classic question around switching values in a column, typically swapping the gender of people in a table for example:
id name sex salary ------------------------ 0 Tom f 45000 1 Jane m 22000
the typical question asks you to do this in one statement (and the answer is here: Switching values in a column with one update statement)
However my question is NOT that.
My question is what is the naive approach, that is, how I can temporarily store the values. In fact I'd like to do this two ways: 1. In a temporary column (that does not persist after the statement) and 2. In a temporary variable.