Data Science, Data Engineering and Data Analytics employees at TIAA uses SQL to analyze financial data trends, including market performance and portfolio analysis, as well as to manage customer data, such as investment history and risk tolerance, for personalized retirement service solutions. Because of this, TIAA asks jobseekers SQL interview questions.
So, to help you practice, we've collected 9 TIAA SQL interview questions – can you solve them?
At TIAA, a financial services provider, our most valuable customers are those who actively invest in our products. We would thus like to identify such individuals – what we refer to as 'power investors'. Please develop a SQL query that identifies power investors based on the number of transactions they have made within the last six months. Assume 50 or more transactions within this period qualifies a user as a power investor.
transaction_id | user_id | transaction_date | product_id | transaction_amount |
---|---|---|---|---|
1001 | 123 | 01/01/2022 00:00:00 | 55001 | 200 |
2051 | 123 | 02/15/2022 00:00:00 | 65002 | 150 |
3025 | 456 | 03/30/2022 00:00:00 | 75003 | 500 |
4102 | 123 | 05/05/2022 00:00:00 | 55001 | 300 |
5181 | 789 | 07/20/2022 00:00:00 | 85004 | 1000 |
The above PostgreSQL query first selects the and counts the number of transactions each user has made from the table. It does this only for transactions that occurred within the last six months by using the WHERE clause with . The groups are then arranged by , only keeping those with 50 or more transactions using the clause. As a result, only "power investors" - users who have performed 50 or more transactions - will be returned.
To practice another SQL customer analytics question where you can solve it right in the browser and have your SQL code instantly executed, try this Walmart Labs SQL Interview Question:
Given a table of TIAA employee salaries, write a SQL query to find all employees who earn more than their own manager.
employee_id | name | salary | department_id | manager_id |
---|---|---|---|---|
1 | Emma Thompson | 3800 | 1 | |
2 | Daniel Rodriguez | 2230 | 1 | 10 |
3 | Olivia Smith | 8000 | 1 | 8 |
4 | Noah Johnson | 6800 | 2 | 8 |
5 | Sophia Martinez | 1750 | 1 | 10 |
8 | William Davis | 7000 | 2 | NULL |
10 | James Anderson | 4000 | 1 | NULL |
employee_id | employee_name |
---|---|
3 | Olivia Smith |
This is the output because Olivia Smith earns $8,000, surpassing her manager, William Davis who earns 7,800.
You can solve this interview question and run your code right in DataLemur's online SQL environment:
First, we perform a SELF-JOIN where we treat the first table () as the managers' table and the second table () as the employees' table. Then we use a clause to filter the results, ensuring we only get employees whose salaries are higher than their manager's salary.
If the solution above is hard to understand, you can find a step-by-step solution with hints here: Well Paid Employees.
The keyword removes duplicates from a query.
Suppose you had a table of TIAA customers, and wanted to figure out which cities the customers lived in, but didn't want duplicate results.
name | city |
---|---|
Akash | SF |
Brittany | NYC |
Carlos | NYC |
Diego | Seattle |
Eva | SF |
Faye | Seattle |
You could write a query like this to filter out the repeated cities:
Your result would be:
city |
---|
SF |
NYC |
Seattle |
For TIAA, a leading financial services provider, an important analysis could be to understand the average amount invested in each type of products on a monthly basis by clients. Given a simplified dataset as follows, write a SQL query to calculate the average monthly investment for each type of products.
The table has the following schema:
investment_id | client_id | investment_date | product_type | investment_amount |
---|---|---|---|---|
8100 | 345 | 01/14/2022 | Mutual Funds | 10000 |
9012 | 198 | 01/28/2022 | Retirement Plans | 5000 |
6283 | 675 | 02/08/2022 | Mutual Funds | 15000 |
7891 | 325 | 02/10/2022 | Securities | 25000 |
4567 | 675 | 02/25/2022 | Securities | 5000 |
We wish to find the average monthly investment for each type of product. Note that you need to use the function in PostgreSQL to extract the month from the .
month | product_type | avg_investment |
---|---|---|
1 | Mutual Funds | 10000.00 |
1 | Retirement Plans | 5000.00 |
2 | Mutual Funds | 15000.00 |
2 | Securities | 15000.00 |
The SQL query will look like this:
This query works by grouping the data by month and product type. For each group, it calculates the average investment amount. In this way, we can analyze the monthly trend of investments for each type of product separately.
Pro Tip: Window functions are a frequent SQL interview topic, so practice all the window function problems on DataLemur
A primary key is a column or set of columns in a table that uniquely identifies each row in the table. The primary key is used to enforce the uniqueness and non-nullability of the rows in the table.
In a SQL database, a primary key is defined using the constraint. For example, say you had a table of :
In this example, the column is the primary key of the TIAA employees table. It is defined as an integer and is marked as the primary key using the constraint.
A table can have only one primary key, but the primary key can consist of multiple columns. For example, say you had a table of TIAA customer transactions:
In the above example, the primary key of the Orders table consists of two columns: TransactionID and ProductID. This means that the combination of OrderID and ProductID must be unique for every row in the table.
As a Data Analyst at TIAA, you are tasked with maintaining an investment portfolio database. The database has two tables: and . The table keeps track of various portfolios created by TIAA advisors for different customers. The table details all the individual securities in each portfolio. Given the below tables, write a SQL query to find the total market value of securities in every portfolio.
portfolio_id | customer_id | creation_date | advisor_id |
---|---|---|---|
1001 | 4501 | 01/08/2021 | 302 |
2002 | 4502 | 03/05/2021 | 405 |
3003 | 4603 | 06/28/2021 | 302 |
4004 | 4701 | 09/17/2021 | 208 |
5005 | 4802 | 11/26/2021 | 405 |
investment_id | portfolio_id | security_name | quantity | market_price |
---|---|---|---|---|
50001 | 1001 | IBM | 50 | 150.00 |
60002 | 2002 | Microsoft | 200 | 250.50 |
70003 | 3003 | Amazon | 35 | 3,250.30 |
80004 | 4004 | Apple | 400 | 175.75 |
90005 | 5005 | Tesla | 150 | 680.20 |
Here is the PostgreSQL query to solve the scenario:
This query joins the and tables on the column. It then groups the result by and calculates the total market value for each portfolio by multiplying the quantity of each security by its market price and summing up these values.
Database views are virtual tables based on the results of a SQL statement. They're just like vanilla tables, except views allow you to create simplified versions of tables or hide sensitive data from certain users.
In PostgreSQL, you can create a view by using the command. Here's an example for the table:
TIAA is a Fortune 100 financial services organization that is the leading provider of financial services in the academic, research, medical, cultural and governmental fields. It manages retirement accounts and offers additional financial services such as mutual funds, brokerage services, and life insurance.
Let's say, the company might be interested in understanding the average return on investment (ROI) for each investment product in a given year to better manage its portfolios. They are seeking SQL expertise to help them with data extraction and analysis.
investment_id | product_id | year | return_on_investment |
---|---|---|---|
101 | 309 | 2018 | 6.5 |
102 | 410 | 2018 | 8.9 |
103 | 410 | 2018 | 7.2 |
104 | 309 | 2019 | 7.8 |
105 | 412 | 2019 | 5.6 |
106 | 309 | 2019 | 6.2 |
107 | 412 | 2019 | 6.5 |
108 | 412 | 2020 | 7.1 |
109 | 410 | 2020 | 9.1 |
year | product_id | average_roi |
---|---|---|
2018 | 309 | 6.5 |
2018 | 410 | 8.05 |
2019 | 309 | 7.0 |
2019 | 412 | 6.05 |
2020 | 410 | 9.1 |
2020 | 412 | 7.1 |
This SQL query uses the AVG() function to compute the average return on investment for each product per year. The GROUP BY clause groups the data by year and product_id, so we get the average ROI for each combination of year and product_id.
To practice a very similar question try this interactive Amazon Highest-Grossing Items Question which is similar for determining top-performing items or this Amazon Average Review Ratings Question which is similar for calculating average metrics.
Given tables of user activity data and product data, calculate the click-through-conversion rate, which is defined as the number of users who viewed a product and then added it to their cart over the total number of users who viewed a product.
Assume you are provided with the following tables:
activity_id | user_id | activity_type | product_id | activity_date |
---|---|---|---|---|
101 | 234 | "VIEW" | 3001 | 2022-06-08 |
102 | 567 | "VIEW" | 3001 | 2022-06-10 |
103 | 234 | "ADD_TO_CART" | 3001 | 2022-06-10 |
104 | 890 | "VIEW" | 4001 | 2022-07-05 |
105 | 234 | "ADD_TO_CART" | 4001 | 2022-07-10 |
product_id | name |
---|---|
3001 | "Product A" |
4001 | "Product B" |
The goal is to find the click-through-conversion rate per product.
This SQL query first creates two Common Table Expressions (CTEs) to find the count of unique views and adds to cart per product. It then joins these CTEs on product_id and calculates the click-through-conversion rate as the ratio of unique adds to unique views. If the view count is zero (to avoid division by zero), NULL is returned as the rate. At last, it joins the result with the products table to get the product name.
To practice a related problem on DataLemur's free online SQL coding environment, try this Meta SQL interview question:
The key to acing a TIAA SQL interview is to practice, practice, and then practice some more! Besides solving the above TIAA SQL interview questions, you should also solve the 200+ FAANG SQL Questions on DataLemur which come from companies like Amazon, Microsoft, Meta, and smaller tech companies.
Each exercise has multiple hints, full answers and most importantly, there's an online SQL code editor so you can right in the browser run your query and have it graded.
To prep for the TIAA SQL interview you can also be helpful to solve SQL questions from other insurance companies like:
Discover how TIAA is harnessing the power of AI with Google Cloud to revolutionize client services!
But if your SQL skills are weak, forget about diving straight into solving questions – go learn SQL with this SQL interview tutorial.
This tutorial covers things like filtering data with boolean operators and filtering groups with HAVING – both of these show up often during SQL interviews at TIAA.
Besides SQL interview questions, the other types of problems to practice for the TIAA Data Science Interview are:
To prepare for TIAA Data Science interviews read the book Ace the Data Science Interview because it's got:
Also focus on the behavioral interview – prep for that using this behavioral interview question bank.