• Skip to primary navigation
  • Skip to content
  • Skip to footer
Thomas Ngo Thomas Ngo Crafting Elegant Solutions Through Code
  • Home
  • Journal
  • Tags
  • About

    Thomas Ngo

    Software Engineer

    • Stanton, California
    • Email
    • GitHub
    • Resume

    SQL problem - Swap Salary

    February 1, 2024 less than 1 minute read

    Page Navigation

    • Problem
    • Solution
    1 min read 71 words

    Problem

    prompt1

    prompt2

    Solution

    To dynamically set a value to a column, we can use UPDATE statement together when CASE…WHEN… flow control statement.

    UPDATE salary
    SET
        sex = CASE sex
            WHEN 'm' THEN 'f'
            ELSE 'm'
        END;
    

    Tags: SQL

    Updated: February 1, 2024

    Share on

    X Facebook LinkedIn Bluesky
    Previous Next

    Leave a comment

    You may also enjoy

    Time Based Key-Value Store in C#

    3 minute read

    Learn how to build a time-based key-value store using a dictionary and binary search in C#.

    Search in Rotated Sorted Array in C#

    2 minute read

    Learn how to search for a target value in a rotated sorted array efficiently using binary search in C#.

    Find Minimum in Rotated Sorted Array in C#

    2 minute read

    Learn how to efficiently find the minimum element in a rotated sorted array using a modified binary search approach in C#.

    Solving Koko Eating Bananas in C#

    2 minute read

    Learn how to find the minimum eating speed for Koko using a Binary Search on Answer strategy in C#.

    • Follow:
    • GitHub
    • LinkedIn
    © 2026 Thomas Ngo.