Swap Salary

Swap Salary

An HR service stores employees in Salary: id UUID, name VARCHAR(100), sex lc_swap_sex_t — an ENUM with two values 'm' and 'f', salary NUMERIC(15,2). With a single SQL query, swap the sex values: every 'm' should become 'f', and every 'f''m'. Use UPDATE. No temporary tables, no SELECT. sex is an ENUM, and PostgreSQL types bare string literals inside CASE as text, which will not assign to an enum column. Cast the literals to the column type ('f'::lc_swap_sex_t), or keep the column itself in one branch (ELSE sex) so it defines the expression's type.

Just INSERT/UPDATE/DELETE — no trailing SELECT needed.

Your query result will appear here

Focus radio
Paused · SomaFM · Fluid