JLL employees write SQL queries daily for analyzing real estate market trends and managing property-related datasets. For this reason JLL frequently asks SQL coding questions during interviews for Data Science, Data Engineering and Data Analytics jobs.
Thus, to help you study, here's 8 JLL SQL interview questions – can you answer each one?
JLL manages a large number of properties internationally. One common analysis that they may need to perform is determining the average rental price of different types of properties in various cities.
Let's assume that 'properties' and 'rentals' are two tables in JLL's database. The 'properties' table contains information about each property, including property_id, type (residential, commercial, etc.), and city. The 'rentals' table has information about rental transactions, such as rental_id, property_id, start_date, and rent_price.
property_id | type | city |
---|---|---|
101 | Residential | Chicago |
102 | Commercial | New York |
103 | Residential | London |
104 | Commercial | Chicago |
105 | Residential | New York |
rental_id | property_id | start_date | rent_price |
---|---|---|---|
501 | 101 | 06/08/2022 | 2000 |
502 | 102 | 06/10/2022 | 4000 |
503 | 103 | 07/18/2022 | 1500 |
504 | 104 | 07/26/2022 | 3500 |
505 | 105 | 07/05/2022 | 2200 |
The task is to write a SQL query that calculates the average rent by property type and city for each month.
Month | City | Property Type | Average Rent |
---|---|---|---|
6 | Chicago | Residential | 2000 |
6 | New York | Commercial | 4000 |
7 | London | Residential | 1500 |
7 | Chicago | Commercial | 3500 |
7 | New York | Residential | 2200 |
This query first joins 'rentals' and 'properties' on 'property_id'. Then the data is grouped by month, city, and property type, and the average rental price is calculated for each group. The results are ordered by month, city, and property type for easy readability.
Pro Tip: Window functions are a frequent SQL interview topic, so practice all the window function problems on DataLemur
Given a table of JLL employee salary data, write a SQL query to find the top three highest paid employees within 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 problem 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 hard to understand, you can find a detailed solution with hints here: Top 3 Department Salaries.
The clause works similarly to the clause, but it is used to filter the groups of rows created by the clause rather than the rows of the table themselves.
For example, say you were analyzing JLL sales data:
This query retrieves the total sales for all products in each region, and uses the clause to only sales made after January 1, 2023. The rows are then grouped by region and the clause filters the groups to include only those with total sales greater than $500k.
As a data analyst at JLL, a leading professional services firm that specializes in real estate and investment management, you're tasked to find the average lease amount per property type in the past year. This would help the company to better understand the trends and dynamics in the local real estate market.
property_id | property_type |
---|---|
1 | Commercial |
2 | Residential |
3 | Industrial |
4 | Commercial |
5 | Residential |
lease_id | property_id | lease_start_date | lease_amount |
---|---|---|---|
101 | 1 | 01/01/2020 | $5000 |
102 | 2 | 15/01/2020 | $3000 |
103 | 1 | 01/02/2020 | $5500 |
104 | 3 | 15/02/2020 | $6000 |
105 | 2 | 01/03/2020 | $2800 |
106 | 4 | 15/03/2020 | $5200 |
107 | 5 | 01/04/2020 | $3500 |
property_type | avg_lease_amount |
---|---|
Commercial | $5233.33 |
Residential | $3150.00 |
Industrial | $6000.00 |
The query first joins the leases and properties tables on the property_id column. It then applies a WHERE condition to filter only leases that started in the past year (from '01/01/2020' to '31/12/2020'). Finally, the calculation for the average lease amount by property type is performed using the AVG function and displayed as avg_lease_amount. The results are grouped by property_type, thus giving us the average lease amount for each type of property from last year.
To practice a very similar question try this interactive Amazon Highest-Grossing Items Question which is similar for calculating top entities based on properties or this Wayfair Y-on-Y Growth Rate Question which is similar for analyzing data over a time period.
A self-join is a type of JOIN where a table is joined to itself. To execute a self-join, you must include the table name twice in the FROM clause and assign a different alias to each instance. You can then join the two copies of the table using a JOIN clause, and use a WHERE clause to specify the relationship between the rows.
One common use case for self-joins is to compare data within a single table. For example, you might use a self-join to compare the salaries of employees within the same department, or to identify pairs of products that are frequently purchased together (like in this real Walmart SQL interview question)[https://datalemur.com/questions/frequently-purchased-pairs].
For a more concrete example, imagine you had website visitor data for JLL, exported from the company's Google Analytics account. To help the web-dev team, you needed to analyze pairs of pages for UX or navigational issues. As part of that analysis, you wanted to produce all pairs of URLs, but needed to exclude pairs where both URLs were the same since that is not a valid pair.
You could use the following self-join:
This query retrieves the url of each page () along with the url of the page that referred to it (). The self-join is performed using the , which identifies the id of the page that referred the visitor to the current page, and excludes any pages that referred to themselves (i.e., data anomalies since pages shouldn't refer to themself).
Read about how JLL uses 3D imaging and data visualization to bring their products and services to the next level!
As a property management company, JLL needs to handle customer data effectively. Suppose you are provided with the customer records database. You need to find all customers whose names start with the letter 'A' and are located in 'New York'.
Please write an SQL query to filter these records using the SQL keyword LIKE.
The following provides example input and expected output:
customer_id | name | age | city | state |
---|---|---|---|---|
1 | Alice | 25 | New York | NY |
2 | Bob | 30 | San Francisco | CA |
3 | Andrew | 35 | New York | NY |
4 | Ann | 40 | Los Angeles | CA |
5 | Amber | 28 | New York | NY |
customer_id | name | age | city | state |
---|---|---|---|---|
1 | Alice | 25 | New York | NY |
3 | Andrew | 35 | New York | NY |
5 | Amber | 28 | New York | NY |
The above query uses the wild card character in conjunction with the operator in SQL to filter out all customer records whose name start with 'A'. The operator is used to further filter the results to include only those customers who are located in 'New York'.
is used to combine the output of multiple statements into one big result!
For a concrete example, say you were doing an HR Analytics project for JLL and needed to analyze both JLL's employees and contractors who were hired after 2022 started. You could use in the following way:
JLL has two key tables in its database: and . The table stores information about each customer, and the table stores information about each real estate transaction made by the customers. The columns in the table include , , , and , whereas the table includes , , , , and .
You are required to write a SQL query that will return a list of customers and the total amount they have spent on real estate transactions. The result should include , , and and should be ordered by in descending order.
customer_id | first_name | last_name | |
---|---|---|---|
1001 | John | Doe | john.doe@example.com |
1002 | Jane | Smith | jane.smith@example.com |
1003 | Bob | Johnson | bob.johnson@example.com |
transaction_id | transaction_date | customer_id | property_id | transaction_amount |
---|---|---|---|---|
2001 | 2022-01-15 | 1001 | 3001 | 200000.00 |
2002 | 2022-02-15 | 1001 | 3002 | 250000.00 |
2003 | 2022-04-22 | 1002 | 3003 | 175000.00 |
2004 | 2022-07-10 | 1003 | 3004 | 225000.00 |
This query initially performs an inner join on the and tables based on the . The grouped output provides a list of customers (first and last names) along with their total spent amount on real estate transactions. The results are presented in descending order of .
Because join questions come up so often during SQL interviews, practice this Spotify JOIN SQL question:
The best way to prepare for a SQL interview, besides making sure you have strong SQL fundamentals, is to practice a ton of real SQL questions that were asked in recent job interviews. Beyond just solving the earlier JLL SQL interview questions, you should also solve the 200+ SQL Interview Questions on DataLemur which come from companies like Microsoft, Google, Amazon, 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 is an online SQL code editor so you can easily right in the browser your SQL query and have it executed.
To prep for the JLL SQL interview you can also be helpful to practice SQL problems from other real estate and REIT companies like:
But if your SQL skills are weak, forget about diving straight into solving questions – strengthen your SQL foundations with this DataLemur SQL tutorial.
This tutorial covers things like WHERE vs. HAVING and rank window functions – both of these pop up often in SQL job interviews at JLL.
In addition to SQL query questions, the other question categories covered in the JLL Data Science Interview are:
You should also familiarize yourself deeply with JLL's Azara Data Insights platform, because your work will likely be supporting this platform in some way!
Besides understanding the company values, and JLLs products, the next best way to prepare for JLL Data Science interviews is to read the book Ace the Data Science Interview.
The book has 201 interview questions sourced from Facebook, Google, & Amazon. It also has a refresher covering SQL, Product-Sense & ML. And finally it's helped thousands of people land their dream job in data, which is why it's got over 1000+ 5-star reviews on Amazon.