At Nokia, SQL is used day-to-day for analyzing and managing vast telecom datasets, and generating reports for network performance tracking and optimization. Because of this, Nokia often tests SQL problems during interviews for Data Science and Data Engineering positions.
So, to help you prepare for the Nokia SQL interview, we've collected 8 Nokia SQL interview questions – can you solve them?
At Nokia, you are given a dataset representing network data usage by users over several months. There is a table called with columns , (timestamp when the data session started), (timestamp when the data session ended), and (total data used in the session in MB).
Your task is to write a query to find the total data used by each user each month using a window function.
user_id | start_time | end_time | data_used |
---|---|---|---|
102 | 2021-08-15 08:20:15 | 2021-08-15 08:30:15 | 152 |
203 | 2021-08-06 10:30:50 | 2021-08-06 12:15:30 | 890 |
102 | 2021-09-08 21:32:22 | 2021-09-08 22:00:22 | 450 |
304 | 2021-09-10 14:15:55 | 2021-09-10 15:00:05 | 520 |
203 | 2021-09-09 00:10:30 | 2021-09-09 01:50:40 | 780 |
month | user_id | total_data_used |
---|---|---|
8 | 102 | 152 |
8 | 203 | 890 |
9 | 102 | 450 |
9 | 203 | 780 |
9 | 304 | 520 |
This SQL query uses a window function with to calculate the sum of data used by each user in each month. The function is used to get the month from the column. The final result is ordered by and . Please note that if you have many users this might not be efficient.
For more window function practice, try this Uber SQL Interview Question within DataLemur's online SQL coding environment:
As a Data Analyst for Nokia, you are tasked with designing a database to store call logs of customers. The database should include tables for customer details, device details, and call logs. The call logs should include call start time, duration, the called number, and the status of the call (i.e., successful or failed).
Once your database design is set, populate it with some data. Then, write a SQL Query using PostgreSQL to find out the average call duration for each customer for the last month.
Sample Data:
customer_id | first_name | last_name |
---|---|---|
1001 | John | Doe |
1002 | Jane | Smith |
1003 | Bob | Johnson |
device_id | model | release_date |
---|---|---|
2001 | Nokia_3310 | 2000-09-01 |
2002 | Nokia_X6 | 2018-05-16 |
2003 | Nokia_1100 | 2003-11-01 |
log_id | customer_id | device_id | call_start | call_duration | called_number | call_status |
---|---|---|---|---|---|---|
9991 | 1001 | 2001 | 2022-11-01 08:30:00 | 5 | 1002 | Successful |
9992 | 1002 | 2002 | 2022-11-01 09:00:00 | 10 | 1003 | Failed |
9993 | 1003 | 2003 | 2022-11-02 12:00:00 | 15 | 1001 | Successful |
9994 | 1001 | 2001 | 2022-11-02 16:30:00 | 20 | 1003 | Successful |
9995 | 1002 | 2002 | 2022-11-03 07:45:00 | 25 | 1001 | Failed |
Provided is the SQL query to find out the average call duration for each customer for the last month.
This SQL query first joins the table and the table on the . Then it filters out all the call logs from the last month. Finally, it groups the results by and , and calculates the average call duration for each customer by using the AVG function.
To normalize a database, tables are divided into smaller, more specialized ones and relationships between them are defined via primary and foreign keys. This minimizes redundancy, making the database more flexible, scalable, and easier to maintain. Normalization also helps to ensure the accuracy of the data by reducing the likelihood of inconsistencies and errors.
Given a database of Nokia's phone sales which includes the amount of each sale, the date of sale, and the phone model sold, can you write a SQL query that calculates the average sale amount per month for each phone model?
Consider the following table .
sale_id | sale_date | product_model | sale_amount |
---|---|---|---|
1001 | 2022-01-05 | Lumia 800 | 200 |
1002 | 2022-01-20 | Lumia 800 | 210 |
1003 | 2022-01-25 | Lumia 520 | 150 |
1004 | 2022-02-10 | Lumia 800 | 220 |
1005 | 2022-02-15 | N95 | 250 |
1006 | 2022-02-20 | Lumia 520 | 170 |
Your task is to provide the following output:
month | product_model | avg_sale_amount |
---|---|---|
1 | Lumia 800 | 205 |
1 | Lumia 520 | 150 |
2 | Lumia 800 | 220 |
2 | N95 | 250 |
2 | Lumia 520 | 170 |
This PostgresSQL query uses the EXTRACT function to get the month from the sale_date column. The output is grouped by both the month and the product_model to calculate the average sale amount for each phone model each month, using the AVG aggregate function. The results will be sorted by month and then by the product_model.
The clause is used to filter the groups created by the clause. It's similar to the clause, but it is used to specify conditions on the groups created by the clause, rather than on the individual rows of the table.
For example, say you were analyzing salaries for analytics employees at Nokia:
This query retrieves the total salary for each Analytics department at Nokia and groups the rows by the specific department (i.e. "Marketing Analytics", "Business Analytics", "Sales Analytics" teams).
The clause then filters the groups to include only Nokia departments where the total salary is greater than $1 million
You are working with Nokia's customer records. The company wants to send out a promotional email to all customers whose email addresses contain the term . Write a SQL query to fetch all records of customers whose email addresses contains the string .
Please use the following table for reference:
customer_id | first_name | last_name | |
---|---|---|---|
123 | John | Doe | john.doe@nokia.com |
265 | Jane | Smith | jane.smith@example.com |
362 | Bob | Brown | bob.brown@nokia.com |
192 | Alice | Green | alice.green@test.com |
981 | Steve | Jobs | steve.jobs@nokia.com |
This query used the keyword with the wildcard character to search for customer records where the column contains the string . The character is a wildcard in SQL that matches any number of characters, so matches any string that contains anywhere in it. The records returned by this query will include all customers whose email addresses contain .
While both types of databases are used to store data (no duh!), relational databases and non-relational (also known as NoSQL databases) differ in a few important ways:
Data model: Relational databases use a data model consisting of tables and rows, while NoSQL databases use a variety of data models, including document, key-value, columnar, and graph storage formats.
Data integrity: Relational databases use structured query language (SQL) and enforce strict data integrity rules through the use of foreign keys and transactions. NoSQL databases may not use SQL and may have more relaxed data integrity rules.
Structure: Relational databases store data in a fixed, structured format, while NoSQL databases allow for more flexibility in terms of data structure.
ACID compliance: Relational databases are typically into shrooms and are ACID-compliant (atomic, consistent, isolated, and durable), while NoSQL databases may not be fully ACID-compliant (but they try their best... and it's effort that counts...or at least that's what my gym teacher told me!)
You are an Analyst at Nokia and your team want to analyze the average call length (in minutes) of specific phone models over a certain time period. Your data comprises a 'PhoneCalls' table that has records for each call made, including the phone model, start timestamp, end timestamp and customer id.
Given this scenario, can you write a SQL query to calculate average call length in minutes for each phone model for the month of 'June 2022'?
call_id | customer_id | start_timestamp | end_timestamp | phone_model |
---|---|---|---|---|
1001 | 601 | 06/04/2022 10:10:00 | 06/04/2022 10:15:30 | Nokia 3310 |
2301 | 702 | 06/14/2022 15:18:20 | 06/14/2022 15:28:20 | Nokia Lumia 520 |
3401 | 804 | 06/25/2022 20:12:00 | 06/25/2022 20:22:30 | Nokia 3310 |
1501 | 908 | 06/28/2022 09:45:30 | 06/28/2022 10:05:30 | Nokia Lumia 520 |
month | phone_model | average_call_length(minutes) |
---|---|---|
June | Nokia 3310 | 7.5 |
June | Nokia Lumia 520 | 15.0 |
The SQL function is used to get the first day of the month for each call's start timestamp. The function calculates call length in minutes. The clause filters calls made only in June 2022. Finally, the clause groups the data by month and phone model to compute the average call time.
Assuming that you've already got basic SQL skills, the next best tip we have to prepare for the Nokia SQL interview is to solve as many practice SQL interview questions as you can! In addition to solving the earlier Nokia SQL interview questions, you should also solve the 200+ SQL Interview Questions on DataLemur which come from companies like Google, Facebook, Microsoft and Amazon.
Each exercise has hints to guide you, full answers and crucially, there is an interactive coding environment so you can right online code up your query and have it checked.
To prep for the Nokia SQL interview you can also be wise to solve SQL problems from other tech companies like:
But if your SQL query skills are weak, don't worry about jumping right into solving questions – improve your SQL foundations with this free SQL tutorial.
This tutorial covers topics including CASE/WHEN/ELSE statements and joining a table to itself – both of these show up routinely in SQL job interviews at Nokia.
Besides SQL interview questions, the other topics to prepare for the Nokia Data Science Interview are:
To prepare for Nokia Data Science interviews read the book Ace the Data Science Interview because it's got: