Rocket Mortgage employees use SQL often for analyzing loan application data, and optimizing mortgage interest rates. That's why Rocket Mortgage covers SQL coding questions in interviews for Data Science, Analytics, and & Data Engineering jobs.
So, to help you practice, here’s 8 Rocket Mortgage SQL interview questions – can you answer each one?
Rocket Mortgage, as a part of Quicken Loans, offers two types of loan products for its customers, 'Fixed-Rate' and 'Adjustable-Rate'. Your task is to evaluate the loan product's performance by calculating the monthly average loan amount.
You are provided with the following datasets.
Example Input:
loan_id | customer_id | loan_date | loan_product | loan_amount |
---|---|---|---|---|
3171 | 123 | 02/06/2022 | Fixed-Rate | 150000 |
9822 | 265 | 03/10/2022 | Fixed-Rate | 168000 |
1293 | 522 | 04/15/2022 | Adjustable-Rate | 230000 |
5352 | 972 | 05/26/2022 | Fixed-Rate | 200000 |
1517 | 188 | 07/09/2022 | Adjustable-Rate | 180000 |
Write a SQL query to calculate the average loan amount for each loan product type monthly. The result should be sorted by month and loan product type.
month | loan_product | avg_loan_amount |
---|---|---|
2 | Fixed-Rate | 150000 |
3 | Fixed-Rate | 168000 |
4 | Adjustable-Rate | 230000 |
5 | Fixed-Rate | 200000 |
7 | Adjustable-Rate | 180000 |
The query uses PostgreSQL's function to get the month from the . This becomes one of the fields we , along with . Then, we simply over the field within each group, which gives us the average loan amount for each product per month. Finally, we both and for clarity in viewing the results.
For more window function practice, try this Uber SQL Interview Question within DataLemur's online SQL coding environment:
Imagine there was a table of Rocket Mortgage employee salaries, along with which department they were in. Write a query to compare the average salary of employees in each department to the company's average salary. Return the comparison result as 'higher', 'lower', or 'same' for each department. Display the department ID, payment month (in MM-YYYY format), and the comparison.
Code your solution to this question and run your code right in DataLemur's online SQL environment:
The solution is LONG – 30+ lines of SQL. You can find a step-by-step solution with hints here: Department vs. Company Salary.
BTW Rocket Mortgage has their own blog page, read this article on American Migration Patterns.
Denormalization is a technique used to improve the read performance of a database, typically at the expense of some write performance.
By adding redundant copies of data or grouping data together in a way that does not follow normalization rules, denormalization improves the performance and scalability of a database by eliminating costly join operations, which is important for OLAP use cases that are read-heavy and have minimal updates/inserts.
Rocket Mortgage is a company that provides online mortgage services. As a data analyst, you've been asked to design the DB tables for tracking Mortgage Applications. Each mortgage application can have multiple statuses, starting from "Received", "Under Review", "Approved", "Rejected", etc. Using SQL, design the tables to store this information.
Each application is tied to a property and a user/customer and has a loan amount. Provide a query that retrieves all applications that are currently under review.
You can assume that each application can go from "Received" status to "Under Review" status only once, and similarly, from "Under Review" to "Approved" or "Rejected".
user_id | name |
---|---|
1001 | John Doe |
1002 | Jane Smith |
property_id | address |
---|---|
3001 | 123 Main St |
3002 | 456 Elm St |
app_id | user_id | property_id | loan_amount |
---|---|---|---|
2001 | 1001 | 3001 | 200000 |
2002 | 1002 | 3002 | 250000 |
status_id | app_id | status | status_date |
---|---|---|---|
1 | 2001 | Received | 12/01/2022 |
2 | 2001 | Under Review | 12/02/2022 |
3 | 2002 | Received | 12/03/2022 |
4 | 2002 | Under Review | 12/04/2022 |
5 | 2002 | Approved | 12/05/2022 |
This query will show the properties that are currently under review. It first joins , , , and tables based on their respective keys. Then, it checks if the status of the application is 'Under Review' and the status_date is the latest one. This gives all applications that are currently under review.
A foreign key is a column or group of columns in a table that refers to the primary key in another table. The foreign key constraint helps maintain referential integrity between the two tables. The table with the foreign key is called the child table, while the table with the candidate key is called the parent or referenced table.
For example, consider a database with two tables: and customer_idcustomer_idcustomer_id` column in Rocket Mortgage customers table.
As a data scientist at Rocket Mortgage, you are given the task to analyze the company's mortgage applications data. Write a SQL query to filter mortgage applications where the application status is 'Rejected' and the loan amount requested is above $500,000.
application_id | customer_id | application_date | loan_amount | status |
---|---|---|---|---|
1001 | 461 | 01/08/2022 | $300,000 | Accepted |
1050 | 962 | 02/10/2022 | $610,000 | Rejected |
2070 | 789 | 03/18/2022 | $450,000 | Accepted |
3080 | 592 | 04/26/2022 | $520,000 | Accepted |
4020 | 981 | 05/05/2022 | $700,000 | Rejected |
This query filters out rows from the table where the column is 'Rejected' and the column is more than $500,000. The SELECT * statement returns all columns from the filtered rows. It therefore returns the , , , , and of mortgage applications fitting the filtering conditions.
In database schema design, a one-to-one relationship between two entities is where each entity is associated with only one instance of the other entity. For example, the relationship between a car and a license plate is one-to-one, because each car can only have one licensce plate, and each licensce plate belongs to exactly one car.
On the other hand, a one-to-many relationship is where one entity can be associated with multiple instances of the 2nd entity. For example, a teacher can teach multiple classes, but each class is associated with only one teacher.
Rocket Mortgage, as a mortgage lending company, would be interested in understanding patterns around the average loan amounts they provide for different types of properties (single family home, multi-family home, condo etc.).
The question could be: What is the average loan amount provided by Rocket Mortgage for each type of property?
loan_id | customer_id | loan_date | property_type | loan_amount |
---|---|---|---|---|
101 | 1789 | 01/05/2021 | single family home | 200000 |
102 | 3456 | 02/18/2021 | condo | 150000 |
103 | 2018 | 03/07/2021 | single family home | 220000 |
104 | 5623 | 04/10/2021 | multi-family home | 300000 |
105 | 7845 | 05/12/2021 | multi-family home | 350000 |
This PostgreSQL query finds the average loan amount for each type of property by grouping the dataset by property type before calculating the average loan amount. The function calculates the average of the loan amount for each property type category.
To practice a very similar question try this interactive Amazon Highest-Grossing Items Question which is similar for calculating top items in categories or this Amazon Average Review Ratings Question which is similar for calculating averages.
Assuming that you've already got basic SQL skills, the next best tip we have to prepare for the Rocket Mortgage SQL interview is to solve as many practice SQL interview questions as you can! In addition to solving the above Rocket Mortgage SQL interview questions, you should also solve the 200+ DataLemur interview questions which come from companies like Microsoft, Google, and Facebook.
Each exercise has multiple hints, fully explained answers along with a discussion board to see how others solved it and crucially, there is an interactive coding environment so you can right in the browser run your SQL query and have it graded.
To prep for the Rocket Mortgage SQL interview you can also be useful to solve interview questions from other mortgage & loan companies like:
However, if your SQL skills are weak, don't worry about going right into solving questions – strengthen your SQL foundations with this DataLemur SQL Tutorial.
This tutorial covers topics including filtering data with WHERE and WHERE vs. HAVING – both of which pop up routinely during Rocket Mortgage SQL assessments.
Beyond writing SQL queries, the other question categories covered in the Rocket Mortgage Data Science Interview are:
I'm a bit biased, but I believe the optimal way to study for Rocket Mortgage Data Science interviews is to read my book Ace the Data Science Interview.
The book solves 201 data interview questions sourced from Microsoft, Amazon & startups. It also has a refresher on SQL, Product-Sense & ML. And finally it's vouched for by the data community, which is why it's got over 1000+ 5-star reviews on Amazon.