9 Leidos SQL Interview Questions (Updated 2024)

Updated on

March 1, 2024

At Leidos, SQL is used day-to-day for analyzing complex data sets in defense contracts and managing structured databases for the national security industry. Unsurprisingly this is why Leidos almost always asks SQL problems in interviews for Data Science, Data Engineering, Data Analytics, and Database Management jobs.

To help you prepare for the Leidos SQL interview, here’s 9 Leidos SQL interview questions – able to answer them all?

Leidos SQL Interview Questions

9 Leidos SQL Interview Questions

SQL Question 1: Identify the Top Purchasing Customers for Leidos

Your task is to identify the top Leidos customers in terms of purchase frequency and total purchase value. In this hypothetical scenario, assume that the entity of primary importance to the business is a software purchase. "Power users" or "VIP users" in this context are the customers who purchase the most frequently and also have the highest total purchase value.

Please consider the following sample tables:

Example Input:
Example Input:


The PostgreSQL query to solve this problem would be:

This query creates two CTEs, and . calculates the total purchases and the total purchase value for each customer. assigns a rank to each customer based on their number of purchases and total purchase value. The main query then joins these CTEs with the table to return the names and email addresses of the top 5 customers, their number of purchases, and total purchase value.

To practice a similar VIP customer analysis question on DataLemur's free online SQL coding environment, try this Microsoft Azure Cloud SQL Interview Question: Microsoft SQL Interview Question: Super Cloud Customer

Sure, here's a sample SQL window function question relating to a dataset that might be relevant to Leidos, a company that provides scientific, engineering, systems integration, and technical services.

SQL Question 2: Analyzing Department Performance

Assume that Leidos has several departments offering different services to clients. The table logs every invoice sent to clients. The dataset contains information about the total invoice value, the date the invoice was issued, and the department that issued the invoice.

The goal is to write a SQL query to calculate the rolling 3-month average of the total invoice values per department.

Example Input:
Example Output:


This query first groups the data by department and invoice month. Then it calculates the rolling average of over the current month and the two preceding months, separately for each department. The clause in the window function ensures that the rolling average is calculated within each department, while the clause and define the 3-month window for each rolling average calculation.

To practice another window function question on DataLemur's free interactive coding environment, try this Amazon SQL question asked in a BI Engineer interview: Amazon SQL Interview Question

SQL Question 3: What does / SQL commands do?

The / operator is used to remove to return all rows from the first SELECT statement that are not returned by the second SELECT statement.

Note that is available in PostgreSQL and SQL Server, while MINUS is available in MySQL and Oracle (but don't worry about knowing which DBMS supports which exact commands since Leidos interviewers aren't trying to trip you up on memorizing SQL syntax).

For a tangible example of in PostgreSQL, suppose you were doing an HR Analytics project for Leidos, and had access to Leidos's contractors and employees data. Assume that some employees were previously contractors, and vice versa, and thus would show up in both tables.

You could use operator to find all contractors who never were a employee using this query:

Leidos SQL Interview Questions

SQL Question 4: Project and Employee Management

As a data manager at Leidos, one of your responsibilities is to create a database system that will effectively manage projects and employees. Each project can be worked on concurrently by one or many employees and each employee can work on multiple projects at a time. Design a schema for this scenario and write a PostgreSQL query to find out the total number of employees working on a specific project, given its ID.

Let's consider three tables: , , and :

Example Input:
101Project A02/20/202205/20/2022
102Project B06/01/202208/01/2022
103Project C04/15/202207/15/2022
Example Input:
001Employee 102/15/2022
002Employee 204/01/2022
003Employee 305/30/2022
Example Input:


This query joins the table with the table based on the project ID. It then selects the project ID and name, counts the number of employee IDs associated with a specific project (indicating the number of employees working on that project), and groups the result by project ID and name. The clause specifies the project ID for which you want to find the total number of associated employees. Replace with the ID of the project you are interested in.

SQL Question 5: How can you select records without duplicates from a table?

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 Leidos 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:

AkashData Analyst
BrittanyData Scientist
CarlosData Engineer
DiegoData Engineer
EvaData Analyst

Then the output from the query would be:

Data Analyst
Data Scientist
Data Engineer

SQL Question 6: Filter Customers based on Contract Type and Status

Leidos is a leading technology services provider in the government, civil, and health sector. As such, the company maintains a database of customers records that contains information about the customer’s contract type, contract status among other details.

Your task is to write an SQL query that returns a list of customers with a "Government" contract type and their contract status is Active. In addition, sort the result by the customer's last name in an ascending order.

Leading zeros should be ignored in customers' IDs.

Example Input:
Example Output:


The above SQL query starts by selecting all the columns we are interested in. The function is used to convert the from a string to an integer, ignoring the leading zeros. The clause limits the rows being selected by only including those where equals 'Government' and is 'Active'. Finally, the clause sorts the result by the in ascending order.

SQL Question 7: What distinguishes a left join from a right join?

A join in SQL allows you to retrieve data from multiple tables and combine it into a single set of results.

To demonstrate the difference between left vs. right join, imagine you had two database tables, an advertising campaigns table which had information on Google Ads keywords and how much was bid for each keyword, and a sales table, which has data on how many products were sold and which Google Ads keyword drove that sale.

: A LEFT JOIN retrieves all rows from the left table (in this case, the table) and any matching rows from the right table (the Sales table). If there is no match in the right table, values will be returned for the right table's columns.

: A RIGHT JOIN retrieves all rows from the right table (in this case, the Sales table) and any matching rows from the left table (the table). If there is no match in the left table, values will be returned for the left table's columns.

SQL Question 8: Average Number of Hours Worked on a Project

As a data analyst at Leidos, a technology company involved in various sectors including defense and intelligence, you're asked to evaluate the average number of hours each employee spends working on a project. Leidos is interested in discussing and improving employee productivity on its projects. You are given access to the "hours" table, which records every hour logged by each employee on different projects over the years.

Example Input:

Calculate the average number of hours, rounded to 2 decimals, each employee spends on their project on a daily basis.

Example Output:


This query groups the "hours" table by "project_id" and "employee_id", then calculates the average of "hours_worked", rounding the result to two decimal places. The result gives the average hours worked per day by each employee for each project they are assigned to.

To practice a very similar question try this interactive Snapchat Sending vs. Opening Snaps Question which is similar for evaluating time distribution or this Amazon Server Utilization Time Question which is similar for analyzing utilization time.

SQL Question 9: Find the average purchase amount of different categories for each customer.

For a company like Leidos, a common database might contain information about customers, their purchases, and product categories. The marketing team wants to understand the average purchase amount that each customer makes in different product categories for better personalization.

Example Input:
Example Input:
Example Input:
2003Home & Kitchen


This SQL query first joins the , and tables on the relevant ids. It then groups the data by customer names and product categories to calculate the average purchase amount for each combination. If a customer hasn't purchased a product in a particular category, they won't appear in the results for that category.

Example Output:
CharlieWilliamsHome & Kitchen330.00

Since joins come up frequently during SQL interviews, try this interactive Snapchat Join SQL question: Snapchat JOIN SQL interview question

How To Prepare for the Leidos SQL Interview

The best way to prepare for a Leidos SQL interview is to practice, practice, practice. Besides solving the earlier Leidos SQL interview questions, you should also solve the 200+ SQL coding questions which come from companies like Google, Uber, and Microsoft. DataLemur Questions

Each problem on DataLemur has hints to guide you, fully explained answers along with a discussion board to see how others solved it and best of all, there is an online SQL code editor so you can instantly run your query and have it checked.

To prep for the Leidos SQL interview you can also be useful to practice SQL problems from other tech companies like:

However, if your SQL foundations are weak, forget about diving straight into solving questions – go learn SQL with this SQL tutorial for Data Scientists & Analysts.

SQL interview tutorial

This tutorial covers SQL topics like filtering data with boolean operators and math functions in SQL – both of these pop up often during SQL job interviews at Leidos.

Leidos Data Science Interview Tips

What Do Leidos Data Science Interviews Cover?

In addition to SQL interview questions, the other topics to prepare for the Leidos Data Science Interview are:

Leidos Data Scientist

How To Prepare for Leidos Data Science Interviews?

To prepare for Leidos Data Science interviews read the book Ace the Data Science Interview because it's got:

  • 201 interview questions sourced from companies like Microsoft, Google & Amazon
  • a crash course on Stats, ML, & Data Case Studies
  • over 900+ reviews on Amazon & 4.5-star rating

Ace the Data Science Interview by Nick Singh Kevin Huo