Parsons Corporation almost always asks SQL query questions during interviews for Data Science and Data Engineering positions. To ace their SQL Interview, we've curated 11 Parsons Corporation SQL interview questions to practice – how many can you solve?
Parsons Corporation would like to understand more about the usage patterns of their key cybersecurity software to identify the so-called "Power Users" or "VIP Users". These "VIP users" are the ones who use the software the most frequently and are vital for business. They can be identified by their high frequency of cybersecurity incident submissions.
Please write a SQL query to determine these users by counting, per user, the number of records for each user_id where the submission_date is within the last 30 days.
submission_id | user_id | submission_date | project_id |
---|---|---|---|
2101 | 123 | 03/05/2023 00:00:00 | 3421 |
9382 | 456 | 03/02/2023 00:00:00 | 8482 |
5293 | 444 | 03/04/2023 00:00:00 | 3421 |
8642 | 123 | 03/06/2023 00:00:00 | 9393 |
4537 | 345 | 03/03/2023 00:00:00 | 8482 |
The output should return the user_id and the number of submissions within the last 30 days, ordered by the number of submissions in descending order.
This SQL query first filters the records that were submitted within the past month. After that it groups them by user_id, and for each user, it will count the number of project submissions. The result will be ordered by the count of submissions from high to low, to easily identify the "VIP-users".
To practice a related customer analytics question on DataLemur's free online SQL coding environment, try this Microsoft Azure Cloud SQL Interview Question:
Parsons Corporation wants to analyze the efforts put into each project by its employees. They would like you to write a SQL query that provides a breakdown of the total hours logged by each employee on each project per month. Additionally, they'd like to see the running cumulative total of hours each employee has logged on a project from the start of the project to each month end.
Here's the table that Parsons Corporation provided:
employee_id | project_id | log_date | hours |
---|---|---|---|
1 | 345 | 01/15/2023 00:00:00 | 6 |
1 | 345 | 02/18/2023 00:00:00 | 8 |
2 | 678 | 01/22/2023 00:00:00 | 7 |
2 | 678 | 02/14/2023 00:00:00 | 9 |
1 | 239 | 01/29/2023 00:00:00 | 5 |
1 | 239 | 02/30/2023 00:00:00 | 10 |
2 | 345 | 01/16/2023 00:00:00 | 8 |
2 | 345 | 02/18/2023 00:00:00 | 6 |
They're expecting a result set that looks as follows:
month | employee_id | project_id | monthly_hours | cumulative_hours |
---|---|---|---|---|
1 | 1 | 345 | 6 | 6 |
1 | 1 | 239 | 5 | 5 |
1 | 2 | 678 | 7 | 7 |
1 | 2 | 345 | 8 | 8 |
2 | 1 | 345 | 8 | 14 |
2 | 1 | 239 | 10 | 15 |
2 | 2 | 678 | 9 | 16 |
2 | 2 | 345 | 6 | 14 |
This SQL makes use of two window functions. The first one sums the hours of each employee for each project in a given month. The second function creates a running total of project hours that each employee has reported from the start of the project to the end of each month.
p.s. Window functions show up super frequently during SQL interviews, so practice the 27+ window function questions on DataLemur
Cross joins and natural joins are two types of JOIN operations in SQL that are used to combine data from multiple tables. A cross join creates a new table by combining each row from the first table with every row from the second table, and is also known as a cartesian join. On the other hand, a natural join combines rows from two or more tables based on their common columns, forming a new table.
One key difference between these types of JOINs is that cross joins do not require common columns between the tables being joined, while natural joins do.
Here's an example of a cross join:
If you have 20 products and 10 colors, that's 200 rows right there!
Here's a natural join example using two tables, Parsons Corporation employees and Parsons Corporation managers:
This natural join returns all rows from Parsons Corporation employees where there is no matching row in managers based on the column.
Parsons Corporation often deals with a multitude of projects. Each project requires a unique set of resources including employees with different skills. Design a relational database that can track:
Each project including their start and end dates.
Each employee including their first name, last name, and the skill(s) they possess.
Each project assignment with the specific employee(s) assigned to work on the project.
Bonus Question: Write a SQL query to find the projects that do not have any employees assigned.
project_id | start_date | end_date |
---|---|---|
101 | 2022-01-01 | 2022-12-31 |
102 | 2022-02-01 | 2022-06-30 |
103 | 2022-05-01 | 2022-09-30 |
employee_id | first_name | last_name | skill |
---|---|---|---|
201 | John | Doe | Engineer |
202 | Jane | Smith | Architect |
203 | Mary | Johnson | Designer |
project_id | employee_id |
---|---|
101 | 201 |
101 | 202 |
102 | 203 |
In the above script, I used a left join operation between the projects and project assignments tables. This operation will match and return all records from projects and matched records from project assignments. If there is no match, the result will be NULL on the side of project assignments.
Then, using the WHERE clause, I filtered out the projects that do not have any corresponding records in the project_assignments table, indicating these projects do not have any employees assigned.
When designing a database schema, 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 car and a license plate - each car has one license plate, and each license plate belongs to one car.
On the other hand, a one-to-many relationship is when one entity can be associated with multiple instances of the other entity. For example, a person can have multiple email addresses, but each email address only relates back to one person.
As a data analyst in Parsons Corporation, you are tasked with the job to filter out some specific customers from the entire customer database. The conditions set by the marketing team are as follows:
Please write an SQL query to retrieve customers fitting these conditions.
customer_id | name | signup_date | city |
---|---|---|---|
6171 | John | 12/12/2019 | Los Angeles |
7802 | Mary | 03/15/2020 | New York |
5293 | Peter | 02/28/2020 | Houston |
6352 | Lucas | 04/05/2020 | New York |
4517 | Emma | 07/15/2020 | Los Angeles |
purchase_id | customer_id | product_id | purchase_date | return_status |
---|---|---|---|---|
1223 | 7802 | 27 | 03/12/2020 | No |
2345 | 7802 | 12 | 03/18/2020 | No |
3455 | 7802 | 91 | 04/10/2020 | No |
4523 | 7802 | 65 | 06/14/2020 | No |
5623 | 5293 | 88 | 05/05/2020 | Yes |
This query first groups the purchase data by customer_id and filters those customers who have made more than 3 purchases and whose return_status is 'No'. It then joins this data with the customers table based on customer_id. Next, it filters out customers who signed up after January 1, 2020, and who are either from New York or Los Angeles. Finally, it retrieves the filtered customer's IDs and names.
A database index is a way to optimize the performance of a database by reducing the amount of data that needs to be searched to retrieve a record.
There are several types of indexes that can be used in a database:
For a concrete example, say you had a table of Parsons Corporation customer payments with the following columns: payment_id, customer_id, payment_amount, and payment_date.
Here's what a clustered index on the column would look like:
A clustered index on the column would determine the physical order of the records in the table based on the . This means that the records with the earliest values would be stored together physically in the table, followed by records with later payment_date values.
Having a clustered index on the column can speed up queries that filter or sort the data based on the payment_date, as the records are already physically sorted in the table. For example, if you want to retrieve all the payments made in the month of January, the database can use the clustered index to quickly locate and retrieve the desired records without having to search through the entire table.
At Parsons Corporation, a construction and engineering firm, Each employee may be assigned to multiple projects and they log their hours for each project separately. As a Data Analyst, you're asked to find the average hours an employee works per project.
Here are the sample tables:
project_id | project_name |
---|---|
1 | Bridge Construction |
2 | Road Repair |
3 | School Building |
employee_id | employee_name |
---|---|
101 | Jake Smith |
102 | Jane Doe |
103 | Mike Johnson |
hours_id | employee_id | project_id | hours |
---|---|---|---|
2001 | 101 | 1 | 40 |
2002 | 101 | 2 | 30 |
2003 | 102 | 1 | 35 |
2004 | 102 | 3 | 25 |
2005 | 103 | 2 | 40 |
The SQL code to find out the average hours per project would be:
This query groups the data by project and calculates the average hours spent on each project. The JOIN operation combines rows from and based on matching project IDs.
To practice a very similar question try this interactive JPMorgan Chase Card Launch Success Question which is similar for calculating metrics over multiple rows.
Parsons Corporation sends out weekly newsletters containing articles on national security topics. Each newsletter contains multiple links to articles. Parsons wants to identify how effective their newsletters are by calculating a click-through rate (CTR). Click-through rate (CTR) is calculated as (Total Clicks on a link / Total Delivered Newsletters) * 100%.
Given two tables, which records all sent newsletters and which records all clicks on an article's link in the newsletters. Calculate the weekly CTR.
newsletter_id | send_date |
---|---|
1 | 2022-06-01 |
2 | 2022-06-08 |
3 | 2022-06-15 |
4 | 2022-06-22 |
5 | 2022-06-29 |
click_id | newsletter_id | click_date |
---|---|---|
101 | 1 | 2022-06-01 |
102 | 1 | 2022-06-02 |
103 | 2 | 2022-06-09 |
104 | 3 | 2022-06-16 |
105 | 3 | 2022-06-16 |
This SQL query first joins the two tables newsletter_sent and newsletter_clicks based on . Then it calculates the total number of clicks and total newsletters sent per week. Finally, it calculates the click-through rate for each week.
This query would result in a new table with each row indicating a distinct week, total clicks on the newsletter, total newsletters delivered, and the corresponding click-through rates.
To solve another question about calculating rates, solve this SQL interview question from TikTok within DataLemur's online SQL coding environment:
Unique indexes help ensure that there are no duplicate key values in a table, maintaining data integrity. They enforce uniqueness whenever keys are added or changed within the index.
To define a unique index in PostgreSQL, you can use the following syntax:
To define a non-unique index in PostgreSQL, you can use the following syntax:
Non-unique indexes on the other hand, are used to improve query performance by maintaining a sorted order of frequently used data values, but they do not enforce constraints on the associated table.
Parsons Corporation is a global leader in diversified markets, focusing primarily on defense, security, and infrastructure. To better understand customer habits, the marketing team wants to identify customers who purchased certain products along with the total amounts they spent on those products.
You have two tables - and . The table has columns , , , . The table has columns , , , . The 1001 and 1002 are of interest.
Write a SQL query to join these two tables and find out the customers' first name, last name, and total amounts spent on the products 1001 and 1002.
customer_id | first_name | last_name | |
---|---|---|---|
1 | Jack | Doe | jdoe@email.com |
2 | Jane | Doe | jane.doe@email.com |
3 | Alice | Cooper | alicecooper@email.com |
4 | Bob | Dylan | bobdylan@email.com |
5 | Charlene | Johnson | charlenejohnson@email.com |
order_id | product_id | customer_id | amount |
---|---|---|---|
1 | 1001 | 1 | 400.00 |
2 | 1002 | 1 | 600.00 |
3 | 1001 | 3 | 250.00 |
4 | 1002 | 4 | 700.00 |
5 | 1001 | 5 | 350.00 |
This query joins the and tables based on , filters orders based on the , then groups the result by to calculate the total amount spent by each customer, and presents the information with customer's first name, last name, and total amount spent. The results are sorted in descending order to show the customers who spent the most at the top.
Since joins come up frequently during SQL interviews, try this interactive Snapchat Join SQL question:
The best way to prepare for a Parsons Corporation SQL interview is to practice, practice, practice. In addition to solving the above Parsons Corporation SQL interview questions, you should also solve the 200+ SQL exercises on DataLemur which come from companies like Amazon, Microsoft, Meta, and smaller tech companies.
Each exercise has multiple hints, fully explained answers along with a discussion board to see how others solved it and crucially, plus there's an online SQL coding environment so you can right in the browser run your query and have it executed.
To prep for the Parsons Corporation SQL interview you can also be a great idea to solve interview questions from other defense & aerospace contractors like:
In case your SQL foundations are weak, don't worry about diving straight into solving questions – improve your SQL foundations with this DataLemur SQL tutorial.
This tutorial covers SQL concepts such as working with string/text data and filtering data with WHERE – both of these pop up often during Parsons Corporation interviews.
For the Parsons Corporation Data Science Interview, besides SQL questions, the other types of questions which are covered:
To prepare for Parsons Corporation Data Science interviews read the book Ace the Data Science Interview because it's got: