SQL Practice Question/Answers 2025

3 most profitable companies

Find the 3 most profitable companies in the entire world. Output the result along with the corresponding company name. Sort the result based on profits in descending order. Soucrs

Dataframe: forbes_global_2010_2014


Case# 2

Find doctors with the last name of ‘Johnson’ in the employee list. The output should contain both their first and last names.

DataFrame: employee_list

Solution

Python Code
import pandas as pd
doc_Johnson = employee_list[(employee_list['profession'] == 'Doctor') & (employee_list['last_name']== 'Johnson')]
table = doc_johnson[['first_name','last_name']]
print(table)
SQL Code
SELECT first_name, last_name
FROM employee_list
WHERE profession = 'Doctor' AND last_name = 'Johnson'