logo

11 Schibsted SQL Interview Questions (Updated 2024)

Updated on

March 2, 2024

At Schibsted, SQL is often used for analyzing user behavior on their digital publications and optimizing ad targeting based on precise customer segmentation. That's why Schibsted LOVES to ask SQL query questions during interviews for Data Science, Data Engineering and Data Analytics jobs.

So, to help you study for the Schibsted SQL interview, we've curated 11 Schibsted SQL interview questions – how many can you solve?

11 Schibsted SQL Interview Questions

SQL Question 1: Analyzing User Behavior with Window Function

Schibsted, a global family of digital consumer brands, needs to monitor user interaction with their online products to optimize user experience and improve their products. As a data analyst, you are tasked to analyze user login behavior from their web logs over a period.

Specifically, you are asked to write a SQL query to analyze the following scenario for each user within a 7-day period:

  1. Count the total number of logins.
  2. Compare each login day with the previous login day within the 7-day window.
  3. Compute the mean number of logins in the 7-day window.

Your task will help Schibsted understand user behavior in terms of sessions.

Example Input:
log_iduser_idsession_date
10011232022-08-01 00:00:00
10021232022-08-02 00:00:00
10031232022-08-04 00:00:00
10041232022-08-07 00:00:00
10053332022-08-01 00:00:00
10063332022-08-03 00:00:00
10073332022-08-05 00:00:00
10083332022-08-07 00:00:00
Example Output:
log_iduser_idsession_datetotal_loginslogin_diffmean_logins
10011232022-08-01 00:00:001null1.00
10021232022-08-02 00:00:00211.50
10031232022-08-04 00:00:00321.67
10041232022-08-07 00:00:00432.00
10053332022-08-01 00:00:001null1.00
10063332022-08-03 00:00:00221.50
10073332022-08-05 00:00:00321.67
10083332022-08-07 00:00:00422.00

Answer:

Here is an example PostgreSQL query for this:


The query first partitions the data by the and in each partition, the rows are ordered by . The then counts the number of logins over a 7-day period and the function compares each login day with the previous login day within the 7-day window. The mean number of logins in the 7-day window is then computed using the function.

To solve a related window function SQL problem on DataLemur's free online SQL code editor, solve this Amazon SQL question asked in a BI Engineer interview: Amazon Highest-Grossing Items SQL Analyis Question

SQL Question 2: Analyzing User Activity on Schibsted Platforms

Schibsted owns a conglomerate of digital consumer brands across media, online marketplaces, and technology ventures. Given the hypothetical scenario that you are provided with two tables, and , design a database to track and analyze user activity on Schibsted platforms.

The table contains two columns: (PK) and . The table has (FK), , and .

For this question, assume Schibsted wants to understand the average time spent by users from each country on each platform per day. Design a PostgreSQL query to find this information.

Sample Data:

Example Input:
user_idcountry
101Norway
102Sweden
103Norway
104France
Example Input:
user_idplatform_idactivity_datetime_spent_in_hours
1012012022-07-012
1022022022-07-011
1012012022-07-021.5
1032022022-07-022
1042012022-07-031

Expected Output:

Example Output:
countryplatform_idactivity_dateavg_time_spent_in_hours
Norway2012022-07-012.00
Sweden2022022-07-011.00
Norway2012022-07-021.50
Norway2022022-07-022.00
France2012022-07-031.00

Answer:


This SQL query joins the and table on and then uses an aggregation function on to give the average time spent by users from each country on each platform per day. The results are grouped by , and and ordered in the same manner for readability.

SQL Question 3: What is a primary key?

A primary key is a special type of column or set of columns in a database table that is used to identify each row in the table. It helps to ensure that all the rows are distinct and prevents null values. Additionally, primary keys play a crucial role in maintaining the accuracy of the data by making sure that there are no duplicate rows. They are also used to establish relationships between tables.

To create a primary key in a SQL database, you can use the constraint. For example, in the table , the column is the primary key.


Schibsted SQL Interview Questions

SQL Question 4: Filtering Customer Records

Given a Schibdsted customer database, write a SQL query to filter customers who have spent more than 1000 units in advertisements and have been a customer for over a year. Assume that the database comprises two tables: one for customer information and another for their transaction history.

The customer information table () is structured as follows:

customer_idsignup_datecategory
6752019-07-21Private
9822021-01-15Commercial
4352020-03-19Private
2912021-06-07Commercial
1132020-01-10Private

The transaction history table () is structured as below:

transaction_idcustomer_idtransaction_dateamount_spent
96436752022-07-20500
75329822022-02-211200
64534352022-08-311500
39522912022-03-10950
72531132022-09-011050

Answer:


This SQL query joins the and tables on . It then filters out customers who haven't been with the company for at least a year, and whose total spending in that first year exceeded 1000 units. The output will list the , , and for customers who meet these criteria.

SQL Question 5: What's the difference between relational and NoSQL databases?

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!)

SQL Question 6: Average Number of Ads Posted by Publishers on Schibsted

Schibsted is one of the largest media groups in Europe. Among other things, they own multiple online classified ads platforms where individual publishers can post advertisements.

Given a table of ad postings, can you write a SQL query to find the average number of ads posted by each publisher on a monthly basis?

Example Input:
posting_idpublisher_idpost_datead_id
101133706/12/20224001
10252606/15/20224002
103133706/18/20224003
10478907/22/20224004
105133707/23/20224005
Example Output:
mthpublisher_idavg_ads
613372.00
65261.00
77891.00
713371.00

Answer:


This SQL query first counts the total ads posted by each publisher for every month using a window function. Then it groups the subquery's result by month and publisher_id and calculates the average number of advertisements posted by a publisher in a month. The EXTRACT function is used to get the month number from the post_date column.

SQL Question 7: Can you explain the concept of a constraint in SQL?

SQL constraints are used to specify rules for the data in a table. They can be applied to single or multiple fields in a table when the table is created, or after the table has been created using the ALTER TABLE command.

For example, say you had a database that stores ad campaign data from Schibsted's Google Analytics account.

Here's what some constraints could look like:


SQL Question 8: Calculate the Monthly Average Revenue by Subscription Type

Schibsted is a company with many digital subscription types, including newspapers and magazines. In the subscriptions table, there's a record for each subscription transaction with the user's id, the date of the transaction, the type of the subscription, and the price. The question is: Can you write a SQL query that calculates the monthly average revenue by each type of subscription?

Example Input:

Example Output:

Answer:

Here is the SQL query that would solve this task in PostgreSQL:


In the above query, we first extract the month from the transaction date. Then we group by the month and the subscription type and find the average price (revenue) for each group. We finally order the results by month. This query calculates the average revenue per subscription type for each month. The AVG function calculates the average value of a numeric column.

SQL Question 9: Filter User Information Based on Email Domain

As a company, Schibsted holds a significant amount of user data. For this exercise, assume that the company wants to target a marketing campaign. They are particularly interested in users who have signed up with a Gmail account. Write a SQL query that would filter all users recorded in the database that have an email registered with Gmail.

Example Input:
user_idusernamecreated_dateemail
201john_doe2022-05-16john_doe@mail.com
356jenny_smith2022-06-10jenny_smith@gmail.com
987jack_jones2022-07-05jack_jones@yahoo.com
104sara_white2022-07-15sara_white@gmail.com
658peter_brown2022-07-21peter_brown@hotmail.com

Answer:


This query uses the keyword in SQL to filter for a specific pattern in the email addresses. The '%' is a wildcard that stands for zero, one, or more characters. This combined with '@gmail.com' ensures we only get email addresses that end with '@gmail.com', returning the user data of those who have registered with a Gmail account.

SQL Question 10: How can you select unique records 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 Schibsted 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:

f_namejob_title
AkashData Analyst
BrittanyData Scientist
CarlosData Engineer
DiegoData Engineer
EvaData Analyst

Then the output from the query would be:

job_title
Data Analyst
Data Scientist
Data Engineer

SQL Question 11: Analyzing Customer and Product Interactions

Find the number of unique customers who bought each product, and the average price of each product. Assume we have two tables, and .

Customers
customer_idfirst_namelast_name
1HansHansen
2KarinKarlsson
3JensJensen
4AnnaAndersson
5MargaretaMagnusson
Purchases
product_idpurchase_idcustomer_idprice
1011150.00
1022275.00
10333100.00
10444125.00
1015250.00
1026175.00
10375100.00
10483125.00
1019450.00
10210575.00

Please note, the is for the individual product and a customer can buy the same product more than once.

Answer:


The above SQL command joins the and tables on the column, which is common to both. Then it groups by . For each , it uses the function to find the number of unique customers, and the function to compute the average price. The result is a table with one row for each product, showing the number of unique customers who purchased that product, and the average price of that product.

Because join questions come up so often during SQL interviews, take a stab at this interactive Snapchat JOIN SQL interview question: Snapchat SQL Interview question using JOINS

Preparing For The Schibsted SQL Interview

The best way to prepare for a SQL interview, besides making sure you have strong SQL fundamentals, is to practice a ton of real SQL questions that were asked in recent job interviews. Beyond just solving the earlier Schibsted SQL interview questions, you should also solve the 200+ DataLemur SQL Interview Questions which come from companies like FAANG tech companies and tech startups. DataLemur Questions

Each problem on DataLemur has hints to guide you, step-by-step solutions and best of all, there's an interactive SQL code editor so you can right in the browser run your SQL query and have it graded.

To prep for the Schibsted SQL interview you can also be wise to solve SQL problems from other tech companies like:

In case your SQL query skills are weak, forget about diving straight into solving questions – go learn SQL with this SQL tutorial for Data Scientists & Analysts.

SQL tutorial for Data Analytics

This tutorial covers SQL topics like math functions in SQL and joining a table to itself – both of which pop up frequently during Schibsted SQL interviews.

Schibsted Data Science Interview Tips

What Do Schibsted Data Science Interviews Cover?

In addition to SQL query questions, the other types of questions to practice for the Schibsted Data Science Interview are:

Schibsted Data Scientist

How To Prepare for Schibsted Data Science Interviews?

The best way to prepare for Schibsted Data Science interviews is by reading Ace the Data Science Interview. The book's got:

  • 201 Interview Questions from Facebook, Google, & Amazon
  • A Refresher on Python, SQL & ML
  • Amazing Reviews (900+ 5-star reviews on Amazon)

Ace the Data Science Interview by Nick Singh Kevin Huo