FastPrepSecond Highest Salary
Problems/Second Highest Salary

Second Highest Salary

Bank of America logoBank of America● EasyNEW GRADONSITE INTERVIEW

Updated Nov 2025

QuestionConstraints

Problem statement

Source note: Reported by three Bank of America new grads from campus hiring drives, in a live technical round after the video step. Each one was asked for an SQL query that gives the second highest salary; one says the table held employees and their salaries.

The reports give no table layout, data or rule for equal salaries. Here, equal salaries count once, and the answer is a single row that holds NULL when the table has fewer than two different salaries. The table and column names and all data are ours.

Our version is about 90% the same as the reported question.

The employees table lists the staff of one bank branch, one row per employee, with each person's yearly salary. Several employees can earn exactly the same amount.

Write a query that returns the second highest salary in the table. Salaries are compared as values, so equal salaries count once: if the two best-paid employees both earn the top amount, the answer is the next smaller amount, not the top amount again.

Return exactly one row with one column, second_highest_salary. When the table has fewer than two different salaries, return that one row with NULL (None in Pandas).

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.

employees

One row per employee of the branch.

ColumnTypeNullableDescription
employee_idPKIntegerNoUnique employee ID.
employee_nameTextNoThe employee's name.
salaryIntegerNoYearly salary.

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
second_highest_salaryIntegerYes—

Row order: any order is accepted. Numeric tolerance: 0.

Constraints

  • The employees table has between 1 and 1000 rows.
  • employee_id values are unique, with 1 <= employee_id <= 100000.
  • employee_name has 1 to 40 characters.
  • 1 <= salary <= 1000000

More Bank of America Onsite Interview questions

  • Centered Star PyramidONSITE INTERVIEW · Seen Nov 2025
  • Employees Without a ManagerONSITE INTERVIEW · Seen Nov 2025
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2025
  • N-th Fibonacci NumberONSITE INTERVIEW · Seen Nov 2025
  • Reverse Each Word in a SentenceONSITE INTERVIEW · Seen Nov 2025
  • Three Numbers That Add Up to a TargetONSITE INTERVIEW · Seen Apr 2025
  • Duplicate RowsONSITE INTERVIEW · Seen Oct 2023
  • Factorial of a NumberONSITE INTERVIEW · Seen Oct 2023
  • Palindrome String CheckONSITE INTERVIEW · Seen Sep 2023
  • Second Largest Element in an ArrayONSITE INTERVIEW · Seen Jun 2023

Similar questions at other companies

  • Delete Duplicate Employee RecordsInfosys · ONSITE INTERVIEWInfosys interview questions
  • Records Created or Updated in a Time WindowPelatro · ONSITE INTERVIEW
  • Top Ten Employee SalariesSolytics Partners · ONSITE INTERVIEW
  • Latest New JobSphere · ONSITE INTERVIEW
  • Employees Whose Manager Left the CompanyZS · ONSITE INTERVIEWZS interview questions
  • Employees Above Average SalaryJP Morgan Chase · ONSITE INTERVIEWJP Morgan Chase interview questions
  • Retrieve Every Student RecordLSEG · ONSITE INTERVIEWLSEG interview questions
  • Combine Winner and Loser NamesAmazon · ONSITE INTERVIEW
  • Conditionally Insert or Update RecordsKlaviyo · ONSITE INTERVIEWKlaviyo interview questions
  • Employees with Matching DepartmentsAMD · ONSITE INTERVIEWAMD interview questions

Bank of America interview experiences

  • Bank of America interviews · December 2025
  • Bank of America OA · December 2025
  • Bank of America interviews · September 2026
  • Bank of America OA · September 2026
All Bank of America interview questionsSee Bank of America hiring insights