When preparing for an interview for a position in the field of SQL development, it is important to be well-versed in the tools and techniques that are commonly used within the industry. In this blog post, we will provide a comprehensive list of the top SQL interview questions that prospective employers might ask during an Uber interview. We will discuss both general and Uber-specific questions, with an emphasis on the latter. Our goal is to give you an overview of the topics that will likely be addressed in the interview process and to provide you with the necessary information to ace the interview. Whether you are a seasoned professional or a recent graduate, the questions outlined in this blog post will help you to better prepare for the interview and get one step closer to landing the job. Furthermore, we will provide some additional resources to help you to practice your SQL skills and increase your chances of success.
Uber SQL Interview Question for Data Scientists and Data Analysts (StrataScratch 10169)
Interviews for Top Jobs at Uber
Data Analyst Interview
I applied online. The process took 4 weeks. I interviewed at Uber in Oct 2021
Interview
O processo em geral foi bem organizado, porem a entrevista em si foi bem confusa, com certa desorganização nas perguntas, claramente sem um preparo prévio. Gestores mal preparados para a entrevista.
- Perguntas como contar experiência prévia.
Data Analyst Interview
I interviewed at Uber
Interview
4 steps of recruitment – HR -> technical assessment -> tech interview -> team interview assessment was too extensive, so I haven’t accomplished this part HR part very friendly – they say everything about the job with salary already in this part
- Why Uber? How do you set priorities? What did you do at your last job?
Want to practice more SQL interview questions like this with on-demand support and a dynamic SQL playground? Learn more here!
Write a query to determine how long passed between each user’s first and second Uber trips. The user must have taken at least two trips.
Output
Solution
Uber SQL Interview Question 57: Find the third order
Write a query to determine how many customers placed their third order with an ATG (holding company) product on or after 9/21/22, only taking orders with at least one ATG holding company product into account.
Output
Solution
Uber SQL Interview Question Walkthrough
Highest Total Miles
We have a table of information that details each trip that has been booked using the Uber app. Candidates are asked to list the top three reasons why business accounts use Uber for transportation.
On the StrataScratch platform, it is classified as “Medium” difficulty, so if you pay attention, you should be able to find a solution. This Uber SQL interview question can be approached in a variety of ways.
You might need to look at the available data because question formulation can be a little confusing in order to understand the question.
Link to the question: https://platform.stratascratch.com/coding/10169-highest-total-miles
start_date | datetime |
end_date | datetime |
category | varchar |
start | varchar |
stop | varchar |
miles | float |
purpose | varchar |
You should read this question several times to fully understand what needs to be done because it is complicated.
It’s helpful to preview the final table or ask the interviewer to describe the expected output for data science interview questions like this one. Utilize this chance to understand the query by working backwards from the outcome.
As you read the question, whenever possible, you should also glance at the actual values in the table. This may facilitate your understanding of the data at hand.
start_date | end_date | category | start | stop | miles | purpose |
---|---|---|---|---|---|---|
2016-01-01 21:11:00 | 2016-01-01 21:17:00 | Business | Fort Pierce | Fort Pierce | 5.1 | Meal/Entertain |
2016-01-02 01:25:00 | 2016-01-02 01:37:00 | Business | Fort Pierce | Fort Pierce | 5 | |
2016-01-02 20:25:00 | 2016-01-02 20:38:00 | Business | Fort Pierce | Fort Pierce | 4.8 | Errand/Supplies |
2016-01-05 17:31:00 | 2016-01-05 17:45:00 | Business | Fort Pierce | Fort Pierce | 4.7 | Meeting |
2016-01-06 14:42:00 | 2016-01-06 15:49:00 | Business | Fort Pierce | West Palm Beach | 63.7 | Customer Visit |
Letâs look at columns in this table:
start_date – Since the question does not require us to determine the length of each trip, we won’t require the precise date and time the trip began.
Similarly to the start_date column, we won’t need any values from the end_date column.
category: We’ll use the values in this column to ensure that we only keep track of business-related expenses.
start – This question is unrelated to the pickup location.
stop – This Uber SQL interview question is unrelated to the final destination.
miles – For each purpose, we must determine the total number of miles. Therefore, we will sum the values in this column.
purpose – The total miles for each purpose will be summed up in our output. So we definitely need values in this column.
Look closely at the types of values in each column in the table to determine what they each stand for. You can decide how to rank purposes by miles by knowing that the “miles” column contains float values, for example.
Candidates should carefully review the values in the purpose column. One crucial detail can be seen if you pay close attention: some drive records have a NULL value in this column. It will be necessary to handle this edge case.
The range of values in each column is something you should look at. The majority of the values in the “category” column are “Business,” indicating that the drive was an expense for a business. But if you look closely, you’ll see that there are some personal expenses thrown in there as well.
After reading the question several times, you can begin planning your strategy.
You should read this Uber SQL interview question several times because it can be challenging to understand. Calculating total miles only for business expenses is one requirement. In other words, “Business” must be entered as the value in the “category” column.
Break down the solution into a few manageable steps. Writing down your approach can help you stay on track. The solution to this question consists of four broad steps:
Filter out the records that arenât business expenses
The records that weren’t business expenses will be filtered out in the first step using a straightforward WHERE statement.
If you examine the data, you’ll see that some records have a blank “purpose” column. In other words, the value in this column is NULL.
We will need to change our WHERE statement to exclude records with an empty “purpose” column and non-business expenses. To do that, we’ll employ the AND logical operator. Only rows that satisfy both of the following requirements will be retained: the value in the category column is “Business,” and the purpose column contains some data.
A straightforward equality operator could be used as the first condition to ensure that the value in the category column equals “Business.” The second condition can be satisfied by writing purpose IS NOT NULL, which will eliminate all empty values.
Calculate total miles for each purpose
We can calculate the total miles for each purpose after we have the filtered table. To do that, we’ll group the results using the GROUP BY statement and the SUM() aggregate function.
Rows will be arranged using the ORDER BY statement in descending order according to the total number of miles for each purpose.
As you can see in the finished table, there will only be two columns: one column will contain aggregate values for each purpose, and the other will be the purpose column, which will contain specific values to represent each group. Finally, we will output three highest values.
Order records in descending order based on total miles value
To tell the rows to be sorted according to the value in the second column, which contains the total miles, we can just write ORDER BY 2.
Output three purposes with highest total miles
The final step is to output the top three uses by total miles. There are two ways to handle this step: one is by using the LIMIT statement. This problem has a very straightforward and likely to be successful solution. 99% of the time.
Utilizing window ranking functions, which typically yield more accurate results, is the alternative solution. We will discuss both methods of solving the issue in the sections that follow.
The LIMIT statement’s obvious benefit is that it is straightforward and simple to understand.
The problem with using LIMIT is that data is unpredictable. There may be a tie for the third and fourth highest total mile purposes. The LIMIT statement would ignore this situation and continue to output the first three values from the table.
Giving you more control over these edge cases are ranking window functions. They permit ties for first, second, or third-place finishes as well as the output of the top three values. Ranking window functions are a better choice if there is a high likelihood of ties.
The miles column contains float values, as can be seen by looking at it. This column’s values will be combined to create the total miles. It’s unlikely that we will end up in a tie because of this.
In this instance, it might be argued that the ease of the LIMIT statement outweighs the potential for a tie to produce an incorrect result. However, you should use one of the RANK() or DENSE_RANK() functions in place of that if you want to guarantee the accuracy of the results.
The best thing you can do is ask because some employers might prefer a more robust approach over LIMIT’s clarity and readability. To demonstrate your critical thinking and overall SQL knowledge, demonstrate how you can approach the problem in both of these ways.
This can demonstrate your ability to interpret the data and pay attention to nuances and details, such as the likelihood that float values won’t be tied.
Be prepared to use window ranking functions if interviewers ask you to. The most crucial thing is to demonstrate that you are aware of the benefits and drawbacks of both solutions.
In order to name the column that stores the total miles of each purpose, we must use the AS command. It should be something descriptive, such as miles_sum.
We can start with getting all records of business expenses.
The output of running this code will include business expenses. It will look something like this:
We can restrict the output to just the two crucial columns, rather than getting an entire row. One will be created using the SUM() aggregate function, and the other is the purpose column. We’ll name the column descriptively using the AS command.
In order to sum up the total miles for each purpose, we can add the GROUP BY clause.
This query will return a result that is somewhat closer to the desired outcome:
The previous query produces a table with an empty column for the total number of miles traveled by records with a NULL(empty) purpose.
Currently, the table is filtered with a single requirement: only keep business expenses while checking the value in the category column.
Another condition can be added to our filter using the AND logical operator. SQL will also check that the value in the purpose column is not null and only keep values that are business expenses.
If we execute the code, we can see that an empty cell is no longer present in the output.
Ordering purchases based on their total mileage will help us determine the answer. The highest should be at the top and the lowest should be at the bottom of the list.
To accomplish that, we’ll use the ORDER BY statement.
Note that we specify the column using the number 2. The second column, miles_sum, will be interpreted by SQL, which will then sort the records according to its contents.
You can run this code to see how close we came to finding the solution:
We must output the first three rows as a final step. We can use a simple LIMIT statement to do so. It is a straightforward solution that, in this case, almost always yields the right response.
It will give us the final, correct expected output:
This method filters out records where the purpose column is empty and the category column contains anything other than “Business” by using a Common Table Expression (CTE). Additionally, we combine the miles for each purpose in the CTE.
From the CTE, we can extract each group of purposes and their corresponding total miles using the SELECT statement.
The values are then ranked in descending order using the RANK() window function. Last but not least, we can use another WHERE clause to only show the records where the rank value is three or less.
This strategy is more reliable because it addresses the unlikely scenario in which the goals might be tied by the total number of miles.
Uber evolved over the past ten years from a small startup to the enormous tech company it is today.
Data gathering and analysis have remained crucial components of its business model over these years. Uber is able to provide a comfortable service at a competitive price thanks to the work of data scientists.
More interview questions for potential data scientists at Uber can be found at “Uber Data Scientist Interview Questions.” For your Uber interview, review the StrataScratch practical questions and brush up on your SQL knowledge to avoid being caught off guard. May 4th, 2022.
FAQ
How do I prepare for Uber interview?
How to respond: Describe what you like about Uber and its offering. Try to concentrate on a specific motivation for joining Uber. You can also speak about the culture of work at Uber and the great employee benefits and why they are important to you. Ensure that they understand Uber is your first choice.
What are the basic SQL questions asked in interview?
- What is the difference between SQL and MySQL?
- What are the different subsets of SQL?
- What do you mean by DBMS? …
- What do you mean by table and field in SQL?
- What are joins in SQL?
- What distinguishes the SQL data types CHAR and VARCHAR2?
- What is the Primary key?
- What are Constraints?
Is SQL interview hard?
Unfortunately, if you’re learning SQL for the first time, these interviews can be intimidating, challenging, and difficult.
Where can I practice SQL interview question?
Everything you need to ace a SQL interview is provided by SQLPad. In your browser, you can watch, learn, and practice data interview coding questions. Every question thoughtfully designed in a business context. One-stop shop to raise the bar on your data skills