At New Relic, SQL is used often for analyzing application performance data to and to find trends in data collected from cloud-based observability tools. That's why New Relic often tests SQL query questions during interviews for Data Analytics, Data Science, and Data Engineering jobs.
So, to help you ace the New Relic SQL interview, this blog covers 10 New Relic SQL interview questions – able to answer them all?
New Relic is an American software analytics company that specializes in monitoring and performance management products for business applications. The company provides a SaaS monitoring platform that collects, stores, and parses web application performance metrics.
Given the nature of New Relic’s services, a 'Whale User' can be defined by, for instance, the frequency and volume of data transmission events, since whale users are likely to generate a lot of data on the platform.
Assume we have the table containing historical data of each transmission event. The challenge here is to write a SQL query that identifies the top 5 users who send the most volume of data over the last month.
Our example tables look like this:
To aim at the top 5 whale users, we need to aggregate the volume of data sent by each user over the past month and order the users by their total data volume in descending order.
This query calculates the sum of for each user () for events that happened in the last month. The results are sorted in descending order by the total data volume and the clause restricts the output to the top 5 users. This gives us the top 5 'Whale Users' for New Relic in the past month.
To practice a similar power-user data analysis problem question on DataLemur's free interactive SQL code editor, try this recently asked Microsoft SQL interview question:
New Relic is a software analytics company, so let's imagine a situation where you're given a dataset logging all user sessions in a certain period, and you're asked to calculate the average session length.
Here is your input data set:
session_id | user_id | session_start | session_end |
---|---|---|---|
1 | 101 | 03/01/2022 09:30:00 | 03/01/2022 10:00:00 |
2 | 102 | 03/01/2022 11:15:00 | 03/01/2022 11:45:00 |
3 | 101 | 03/01/2022 15:30:00 | 03/01/2022 16:00:00 |
4 | 103 | 04/01/2022 09:10:00 | 04/01/2022 09:30:00 |
5 | 102 | 04/01/2022 13:45:00 | 04/01/2022 14:15:00 |
Each row represents one session for a user, defined by a start time and end time.
The question you should answer is: what is the average session length for each user, in minutes?
Here is the required output:
user_id | average_session_length |
---|---|
101 | 30 |
102 | 30 |
103 | 20 |
Here is a SQL query you could write in PostgreSQL to get this result:
This query works by subtracting the from the for every row in the table resulting in an interval, it then extracts this interval as epochs (in seconds), and divides by 60 to convert to minutes. After obtaining the session lengths in minutes, it calculates the average session length for each user by grouping by and averaging the session lengths.
To solve a similar window function question on DataLemur's free online SQL coding environment, try this Google SQL Interview Question:
In SQL, both a left and right join is used to combine rows from different tables based on a shared key or set of keys, resulting in a single merged table of data. However, here's the difference:
LEFT (OUTER) JOIN: Retrieves all the records/rows from the left and the matched records/rows from the right table.
RIGHT (OUTER) JOIN: Retrieves all the records/rows from the right and the matched records/rows from the left table.
As a data analyst at New Relic, your role would involve providing insights into software application performance data. One essential metric is the server response time, which could be crucial in identifying and addressing performance issues.
Your task is to find out the average server response time for each application on a daily basis.
perf_id | application_id | date | server_response_time_in_ms |
---|---|---|---|
101 | 5000 | 2022-01-01 | 800 |
102 | 5000 | 2022-01-01 | 820 |
103 | 5000 | 2022-01-02 | 750 |
104 | 5001 | 2022-01-01 | 1200 |
105 | 5001 | 2022-01-01 | 1300 |
date | application_id | average_response_time |
---|---|---|
2022-01-01 | 5000 | 810 |
2022-01-02 | 5000 | 750 |
2022-01-01 | 5001 | 1250 |
This SQL query groups the data by date and application ID to calculate the daily average server response time for each application. The AVG function is used to compute the average server response time in milliseconds.
To practice a very similar question try this interactive Amazon Server Utilization Time Question which is similar for calculating total utilization time or this Facebook Average Post Hiatus (Part 1) Question which is similar for daily calculations over data.
An index in a database is a data structure that helps to quickly find and access specific records in a table.
For example, if you had a database of New Relic customers, you could create a primary index on the column.
Having a primary index on the column can speed up performance in several ways. For example, if you want to retrieve a specific customer record based on their , the database can use the primary index to quickly locate and retrieve the desired record. The primary index acts like a map, allowing the database to quickly find the location of the desired record without having to search through the entire table.
Additionally, a primary index can also be used to enforce the uniqueness of the column, ensuring that no duplicate values are inserted into the table. This can help to prevent errors and maintain the integrity of the data in the table.
New Relic, a digital intelligence company, wants to measure the click-through rate from their product page to the page where the customer adds the product to their cart. They are interested in two aspects:
To help analyze this, you have two tables:
One table "page_visits"
visit_id | user_id | visit_date | product_id |
---|---|---|---|
7012 | 812 | 08/01/2022 00:00:00 | 71001 |
8032 | 601 | 08/03/2022 00:00:00 | 31512 |
5462 | 400 | 08/05/2022 00:00:00 | 71001 |
7100 | 142 | 08/06/2022 00:00:00 | 31512 |
4870 | 912 | 08/10/2022 00:00:00 | 71001 |
Another table "cart_adds"
add_id | user_id | add_date | product_id |
---|---|---|---|
2154 | 812 | 08/01/2022 00:01:00 | 71001 |
2053 | 601 | 08/03/2022 00:02:00 | 31512 |
2341 | 400 | 08/05/2022 00:03:00 | 71001 |
First, let's answer what is the total click-through-rate for all products.
Next, let's answer which product had the most successful click-through-rate.
The first part of this block computes the total click-through rate. The second part computes the click-through rate per product, and returns the product with the highest click-through rate. It does so by joining the two tables on the user_id and product_id and counting the number of adds and visits for each product, then dividing the number of adds by the number of visits for the click-through rate.
To solve another question about calculating rates, solve this TikTok SQL Interview Question on DataLemur's interactive coding environment:
The SQL command merges the results of multiple statements and keeps only those rows that are present in all sets.
For example, say you were doing an HR Analytics project for New Relic, and had access to New Relic's employees and contractors 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 also show up in the employees table:
New Relic is a software analytics company that offers cloud-based software to help website and application owners track the performance of their services.
For this exercise, we have a table named that tracks the response times per application on a daily basis. The goal is to write an SQL query that finds the average response time for each application for the past 30 days.
log_id | application_id | date | response_time |
---|---|---|---|
6072 | 110 | 06/03/2022 | 500 |
7639 | 205 | 06/08/2022 | 850 |
5176 | 307 | 06/13/2022 | 400 |
6284 | 110 | 06/19/2022 | 550 |
4357 | 205 | 06/23/2022 | 750 |
8449 | 307 | 06/29/2022 | 450 |
9572 | 110 | 07/03/2022 | 600 |
6734 | 205 | 07/08/2022 | 700 |
5915 | 307 | 07/13/2022 | 500 |
The result should be a table that includes each unique and its average over the last 30 days.
application | avg_response_time |
---|---|
110 | 550 |
205 | 766.67 |
307 | 450 |
This query first filters the data for the last 30 days. It then groups the data by and calculates the average for each group. The result is a list of applications with their average response times.
At New Relic, we have a Customer Records database where each row represents a unique customer's interaction with our business. A typical row in this table includes columns for customer_id, customer_name, interaction_date, and resource_used (the specific resource/service the customer used).
Find all customers who interacted with our 'APM' (Application Performance Monitoring) resource during the month of June 2022. The resource_used column should contain the string 'APM' and the interaction_date should fall in June 2022.
customer_id | customer_name | interaction_date | resource_used |
---|---|---|---|
1034 | Alice Marlow | 06/05/2022 00:00:00 | APM |
5786 | John Smith | 05/15/2022 00:00:00 | APM |
6784 | Rachel Green | 06/18/2022 00:00:00 | Browser |
2454 | Monica Geller | 07/04/2022 00:00:00 | APM |
3890 | Danny Wong | 06/09/2022 00:00:00 | APM |
customer_id | customer_name |
---|---|
1034 | Alice Marlow |
3890 | Danny Wong |
This query uses the keyword to filter rows in the table where the is 'APM'. It then uses the function to extract the month and year from the and ensure that the interaction happened in June 2022.
The clause in SQL allows you to select records that are unique, eliminating duplicates.
For example, if you had a table of New Relic employees, and wanted to see what are all the unique job titles that currently worked at the company, you could write the following query:
Assuming that you've already got basic SQL skills, the next best tip we have to prepare for the New Relic SQL interview is to solve as many practice SQL interview questions as you can! Beyond just solving the above New Relic SQL interview questions, you should also solve the 200+ SQL Interview Questions on DataLemur which come from companies like FAANG and tech startups.
Each exercise has multiple hints, step-by-step solutions and crucially, there's an online SQL coding environment so you can easily right in the browser your SQL query answer and have it graded.
To prep for the New Relic SQL interview you can also be useful to solve SQL questions from other tech companies like:
But if your SQL skills are weak, don't worry about jumping right into solving questions – refresh your SQL knowledge with this interactive SQL tutorial.
This tutorial covers SQL concepts such as creating summary stats with GROUP BY and aggregate functions like SUM()/COUNT()/AVG() – both of which pop up often during New Relic SQL assessments.
Besides SQL interview questions, the other topics to practice for the New Relic Data Science Interview are:
To prepare for New Relic Data Science interviews read the book Ace the Data Science Interview because it's got: