Problem · Database

Null-Safe Full Name

Easyinfosys logoinfosysNEW GRADONSITE INTERVIEW

Problem statement

The table people contains one row per person. Return person_id and a full_name made from first_name, middle_name, and last_name.

Skip every NULL name part and join the remaining parts with exactly one ASCII space. Return every person in ascending person_id order.

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

One row per person.

ColumnTypeNullableDescription
person_idPKIntegerNo
first_nameTextNo
middle_nameTextYes
last_nameTextYes

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
person_idIntegerNo
full_nameTextNo

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

Constraints

  • 1 <= people.length <= 200000
  • person_id is unique.
  • first_name is non-NULL.
  • Every non-NULL name part is non-empty, contains at most 100 characters, and has no leading or trailing whitespace.

More infosys problems