At Stifel Financial, SQL is crucial for analyzing financial market trends and managing client investment portfolios. So, it shouldn't surprise you that Stifel typically asks SQL query questions in interviews for Data Analyst, Data Science, and BI jobs.
Thus, to help you practice for the Stifel SQL interview, we've curated 9 Stifel Financial SQL interview questions – scroll down to start solving them!
Stifel is a financial services holding company that provides investment banking, trading, investment advisory, and related financial services to individual investors, businesses, and municipalities.
To analyze their operations, say the company holds monthly feedbacks, where customers rate a variety of their financial products on a 5-star scale (). The table has columns , , , , and .
Write a query to calculate the average monthly rating for each product. Please use a SQL window function in your query.
review_id | user_id | submit_date | product_id | stars |
---|---|---|---|---|
6171 | 123 | 2022-06-08 | 50001 | 4 |
7802 | 265 | 2022-06-10 | 69852 | 4 |
5293 | 362 | 2022-06-18 | 50001 | 3 |
6352 | 192 | 2022-07-26 | 69852 | 3 |
4517 | 981 | 2022-07-05 | 69852 | 2 |
month | product_id | avg_stars |
---|---|---|
6 | 50001 | 3.5 |
6 | 69852 | 4.0 |
7 | 69852 | 2.5 |
This query leverages the window function capability of calculating the average star rating per month for each product. It partitions the data by and month (extracted using the function). Then it finds the average within each partition using the function. It does all these computations while maintaining the original rows of the table.
p.s. Window functions show up super frequently during SQL interviews, so practice the 27+ window function questions on DataLemur
Given a table of Stifel employee salaries, write a SQL query to find the top 3 highest paid employees in each department.
employee_id | name | salary | department_id |
---|---|---|---|
1 | Emma Thompson | 3800 | 1 |
2 | Daniel Rodriguez | 2230 | 1 |
3 | Olivia Smith | 2000 | 1 |
4 | Noah Johnson | 6800 | 2 |
5 | Sophia Martinez | 1750 | 1 |
8 | William Davis | 6800 | 2 |
10 | James Anderson | 4000 | 1 |
department_id | department_name |
---|---|
1 | Data Analytics |
2 | Data Science |
department_name | name | salary |
---|---|---|
Data Analytics | James Anderson | 4000 |
Data Analytics | Emma Thompson | 3800 |
Data Analytics | Daniel Rodriguez | 2230 |
Data Science | Noah Johnson | 6800 |
Data Science | William Davis | 6800 |
Test your SQL query for this interview question directly within the browser on DataLemur:
We use the DENSE_RANK() window function to generate unique ranks for each employee's salary within their department, with higher salaries receiving lower ranks. Then, we wrap this up in a CTE and filter the employees with a ranking of 3 or lower.
If the solution above is tough, you can find a detailed solution with hints here: Top 3 Department Salaries.
If you want to return records with no duplicates, you can use the keyword in your statement.
For example, if you had a table of Stifel employees, and wanted to see what are all the unique job titles that currently worked at the company, you could write the following query:
If had the following data:
f_name | job_title |
---|---|
Akash | Data Analyst |
Brittany | Data Scientist |
Carlos | Data Engineer |
Diego | Data Engineer |
Eva | Data Analyst |
Then the output from the query would be:
job_title |
---|
Data Analyst |
Data Scientist |
Data Engineer |
As part of the Wealth Management section of Stifel, you have a variety of clients with different earnings from their investments. To target the top earners for specific marketing campaigns, you need to identify the top 5 clients as per their total earnings in the last year.
Sample data:
client_id | client_name | client_email |
---|---|---|
101 | John Doe | johndoe@example.com |
102 | Jane Smith | janesmith@example.com |
103 | Mark Johnson | markjohnson@example.com |
104 | Linda Williams | lindawilliams@example.com |
105 | Michael Brown | mbrown@example.com |
transaction_id | client_id | transaction_date | earnings |
---|---|---|---|
3001 | 101 | 2021-08-01 | 10000 |
3002 | 102 | 2021-09-05 | 15000 |
3003 | 101 | 2021-10-10 | 6000 |
3004 | 103 | 2021-09-20 | 9000 |
3005 | 104 | 2021-11-25 | 12000 |
Example Output:
client_name | client_email | total_earnings |
---|---|---|
John Doe | johndoe@example.com | 16000 |
Jane Smith | janesmith@example.com | 15000 |
Michael Brown | mbrown@example.com | 12000 |
Mark Johnson | markjohnson@example.com | 9000 |
In the solution, we use a JOIN statement to combine the and table based on their common column . Filtering only those transactions that happened within the last year. It sums up all the earnings from each client, ordered it in descending order, and limited the result to the top 5. Hence, we get the list of top 5 earners.
Here is an example of a clustered index on the column of a table of Stifel customer transactions:
This creates a clustered index on the column, which will determine the physical order of the data rows in the table.
Here is an example of a non-clustered index on the column of the same table:
This will create a non-clustered index on the column, which will not affect the physical order of the data rows in the table.
In terms of query performance, a clustered index is usually faster for searches that return a large number of records, while a non-clustered index is faster for searches that return a small number of records. However, updates to a clustered index are slower, as they require the data rows to be physically rearranged, while updates to a non-clustered index are faster, as they only require the index data structure to be updated.
Stifel is a financial company that wants to offer an incentive to their customers for the first time. The criteria for the incentive are as follows:
To identify such customers, write a SQL query that filters down customers meeting the above criteria from Stifel's customer records database.
customer_id | account_balance | join_date | last_transaction |
---|---|---|---|
101 | 12,500 | 2010-08-01 | 600 |
102 | 9,700 | 2015-02-14 | 1200 |
103 | 22,000 | 2020-06-11 | 250 |
104 | 15,000 | 2019-10-21 | 520 |
105 | 7,500 | 2011-05-26 | 800 |
customer_id | account_balance | join_date | last_transaction |
---|---|---|---|
101 | 12,500 | 2010-08-01 | 600 |
104 | 15,000 | 2019-10-21 | 520 |
This query first filters customer records based on the account balance, then filters the resulted records for the join date that is a year from the current date, and finally, filters records to find customers whose last transaction was more than $500. The output table will have the customer records that meet all 3 criteria.
In database schema design, a one-to-one relationship between two entities is characterized by each entity being related to a single instance of the other. An example of this is the relationship between a US citizen and their social-security number (SSN) - each citizen has one SSN, and each SSN belongs to one person.
On the other hand, a one-to-many relationship is when one entity can be associated with multiple instances of the other entity. A teacher's relationship with their classes is an example of this - a teacher can teach many classes, but each class is only associated with one teacher.
Suppose you are working as a data analyst at Stifel, a wealth management and investment banking firm. The company wants to know the average transaction value for each client account for the year 2022. Stifel specifically wants a breakdown of this average monthly. You have access to the table. This table records every transaction made by a client.
Here's what the table looks like:
transaction_id | client_id | account_id | transaction_date | transaction_value |
---|---|---|---|---|
1 | 789 | abc | 01-01-2022 | 5000 |
2 | 123 | xyz | 01-15-2022 | 10000 |
3 | 789 | abc | 02-05-2022 | 3000 |
4 | 123 | xyz | 02-18-2022 | 2000 |
5 | 789 | abc | 03-01-2022 | 6000 |
You need to write a SQL query to find the average transaction value for each client account per month in 2022.
This problem can be solved by grouping data on , and extracting the month from . Then we can compute the average using the function for .
Here is the SQL query:
client_id | account_id | month | avg_transaction_value |
---|---|---|---|
789 | abc | 1 | 5000 |
123 | xyz | 1 | 10000 |
789 | abc | 2 | 3000 |
123 | xyz | 2 | 2000 |
789 | abc | 3 | 6000 |
To practice a very similar question try this interactive Stripe Repeated Payments Question which is similar for dealing with transaction data or this Amazon Average Review Ratings Question which is similar for calculating averages for each month.
Check out the Stifel career page and see what role is the best fit for you!
As part of Stifel's quantitative research team, we often need to pull up data about our customer's trading activities, especially when we are looking into trading trends in specific regions.
Given the table which records the customer's id, name, email, and address, write an SQL query to find all customers whose address contains the term 'MO' (an abbreviation for the state of Missouri).
customer_id | name | address | |
---|---|---|---|
001 | John Doe | john@example.com | 123 Main St, Springfield, MO |
002 | Jane Smith | jane@example.com | 456 Elm St, Kansas City, KS |
003 | Bob Johnson | bob@example.com | 789 Oak St, St. Louis, MO |
004 | Alice Williams | alice@example.com | 321 Pine St, Seattle, WA |
005 | Charlie Brown | charlie@example.com | 654 Maple St, Springfield, IL |
customer_id | name | address |
---|---|---|
001 | John Doe | 123 Main St, Springfield, MO |
003 | Bob Johnson | 789 Oak St, St. Louis, MO |
Here's a simple SQL query that will solve this task:
This query filters the table for records in which the column contains the substring ', MO'. The percent signs are wildcards that match any sequence of characters; thus the filter will match any address that ends in ', MO', consistent with the typical format of addresses in English-speaking countries. The output table includes the , and columns of the matching records, providing the information needed to identify and contact these customers.
The best way to prepare for a Stifel SQL interview is to practice, practice, practice. In addition to solving the above Stifel SQL interview questions, you should also solve the 200+ SQL questions from real Data Science & Analytics interviews which come from companies like FAANG and tech startups.
Each SQL question has hints to guide you, fully explained answers along with a discussion board to see how others solved it and most importantly, there's an interactive SQL code editor so you can easily right in the browser your SQL query answer and have it graded.
To prep for the Stifel SQL interview it is also useful to solve SQL questions from other banking & finanacial services companies like:
In case your SQL foundations are weak, forget about jumping right into solving questions – strengthen your SQL foundations with this DataLemur SQL Tutorial.
This tutorial covers things like handling NULLs in SQL and math functions – both of these come up routinely in SQL interviews at Stifel.
In addition to SQL interview questions, the other types of questions covered in the Stifel Data Science Interview are:
To prepare for Stifel Data Science interviews read the book Ace the Data Science Interview because it's got: