FastPrepSwap Two Gender Values

Swap Two Gender Values

Infosys logoInfosys● EasyFULLTIMEPHONE SCREEN

Problem statement

The people table contains one row per person with person_id and a gender value that is either male or female.

Return every row after swapping male to female and female to male. Return the columns person_id and gender, ordered by person_id ascending.

Table schema

MySQLPostgreSQLPandas

Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.

people

ColumnTypeNullableDescription
person_idIntegerNo—
genderTextNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
person_idIntegerNo—
genderTextNo—

Row order: must match exactly. Numeric tolerance: 0.

Constraints

  • 0 <= people row count <= 100000.
  • person_id is a unique non-null integer.
  • gender is non-null and equals either male or female.

Source note: The source image is a source-neutral excerpt of the author-reported prompt.

More Infosys problems

See Infosys hiring insights