An HR system stores employee records in the Salary table: id UUID, name VARCHAR(100), sex lc_swap_sex_t — an ENUM with the two values 'm' and 'f' — and salary NUMERIC(15,2). In a single SQL statement, swap the sex values for all employees: every 'm' must become 'f', and every 'f' must become 'm'. Use UPDATE. Do not use intermediate tables or run a separate SELECT.
The sex column is an ENUM. PostgreSQL treats string literals inside a CASE expression as type text, so they cannot be assigned directly. Either cast the literals to the column's type ('f'::lc_swap_sex_t) or use the column itself in one of the branches (ELSE sex), allowing it to determine the expression's type. In MySQL, no cast is needed.
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in