logo

9 Adyen SQL Interview Questions (Updated 2024)

Updated on

February 14, 2024

At Adyen, SQL is used to query their internal Graph Database. Data Analysts and Data Scientists analyze transactional data for fraud detection, and manage customer data for personalized marketing strategies. That's why they almost always evaluates jobseekers on SQL questions during interviews for Adyen Data Science and Data Engineering positions.

As such, to help you prepare for the Adyen SQL interview, we've collected 9 Adyen SQL interview questions – how many can you solve?

9 Adyen SQL Interview Questions

SQL Question 1: Calculate the total revenue per merchant per month

At Adyen, we process countless transactions from various merchants every day. We're interested in knowing the total revenue we generate from each merchant on a monthly basis. We have a table that stores all the transaction information - this includes the , , and . The is the total transaction value that is processed through us.

Write a SQL query using window functions to calculate the total revenue generated per merchant per month.

Here is a small sample of data from the table for this SQL problem:

Example Input:

transaction_idmerchant_idtransaction_dateamount
1500101/15/2022100.00
2500201/20/2022500.00
3500101/30/2022300.00
4500202/10/2022200.00
5500102/20/2022100.00

We want to receive the output in this format:

Example Output:

mthyearmerchant_idtotal_revenue
120225001400.00
120225002500.00
220225001100.00
220225002200.00

Answer:

Here's a SQL query that achieves this:


In this query, we're leveraging the Window Function's ability to calculate an aggregate (SUM) over a specified partition. The clause works similarly to , but it retains the original row-level information. It's grouping results by , and also by the Month and Year from .

To solve another window function question on DataLemur's free interactive SQL code editor, solve this Google SQL Interview Question: Google SQL Interview Question

SQL Question 2: Calculate Average Transaction Amount

As a part of your role in Adyen, a global payment company, you are required to find out the average transaction amount per merchant in the previous quarter to spot the highest earning merchants and sustain business relations. Build a SQL query to solve this problem.

Please find below the sample data:

Example Input:
transaction_idmerchant_idtransaction_datetransaction_amount
100150104/10/2022 00:00:00100.50
100250204/15/2022 00:00:00350.00
100350105/01/2022 00:00:0080.00
100450305/25/2022 00:00:00550.00
100550206/15/2022 00:00:00450.00

Answer:

The SQL block which solves the problem is as follows:


In this solution, we would first filter the transactions that happened in the last quarter (From April 1 to June 30). Then we group these transactions by and calculate average (AVG function in SQL) transaction amount for each merchant. The results are ordered in descending order to show the merchants with highest average transaction amount first.

The most similar questions to your are:

  1. "Highest-Grossing Items" by Amazon: It also deals with finding highest earning items like your question.
  2. "Repeated Payments" by Stripe: This question also requires understanding of transaction data similar to your question.

To practice a very similar question try this interactive Amazon Highest-Grossing Items Question which is similar for requiring calculations on earnings or this Stripe Repeated Payments Question which is similar for involving transaction data.

SQL Question 3: How does differ from ?

is used to combine the output of multiple statements into one big result!

Suppose you were a Data Analyst at Adyen working on a Sales Analytics project, and had data on sales leads from both the company's Salesforce CRM and it's legacy Hubspot CRM. To write a query to analyze leads created before 2023 started, across both CRMs, you could use in the following way:


filters out duplicates, so each email/job title/company only shows up once (even if it's in both Salesforce and HubSpot CRMs).

On the other hand, the operator does NOT filter out duplicates, so if a lead shows up in both CRMs, it'll be listed twice in the output of .

Adyen SQL Interview Questions

SQL Question 4: Calculate the Average Daily Processing Volume for Each Merchant

As an assistant in Adyen, a global payment company, you are tasked to generate a report which shows the average daily volume of transactions for each merchant, over a certain month. The volume of a transaction is based on its amount.

The table contains the following columns:

  • (integer)
  • (Date)
  • (integer)
  • (float) - The amount of money processed in the transaction.

Generate a query that will output each merchant's ID, the month, and their respective average daily transaction volume for that month.

Example Input:
transaction_iddatemerchant_idamount
1012022-08-01150000
1022022-08-02170000
1032022-08-01280000
1042022-08-03155000
1052022-08-03289000
1062022-08-02265000
Example Output:
monthmerchant_idavg_daily_volume
8158333.33
8278000.00

Answer:


In this query, we are using the statement to divide the rows in our table into groups, based on the month and merchant_id. Then with each group, we average the transaction amount (volume) to get their respective average daily transaction volume. The function ignores NULL values. EXTRACT function is used to get the month from the date column.

Please note that this solution assumes that there are transactions every day. If that is not the case an additional subquery would be needed to calculate the number of days with transactions for each merchant, and that value should be used to divide the SUM(amount).

SQL Question 5: When considering database normalization, how do 1NF, 2NF, and 3NF differ from one another?

Normalization is the process of dividing a larger table into smaller tables, to eliminate redundancy and dependency. Although there are 5 levels of normalization (normal forms), the 3 most important ones that you should know for the Adyen SQL interview are:

  1. First Normal Form (1NF): Remove a table's duplicate columns, and make sure each value in the column is a singular value (no containers or lists of data). Each row of table should have a unique identifier as well.
  2. Second Normal Form (2NF): A table is in 2NF if it meets all requirements of the 1NF the non-key columns are dependent only on the primary key. You do this by separating subsets of columns subsets, and associating the tables by using primary/foreign keys.
  3. Third Normal Form (3NF): The table should be in 2NF and there shouldn't be any dependency on any non-key attributes (meaning a primary key should be the only thing needed to identify a row).

SQL Question 6: Identify Customers from Specific Country

As an Adyen analyst, you are provided with a database of customer records. Your task is to find all customers that have a billing address in "Netherlands". Keep in mind that the column storing their address is in the format Street, City, Country.

Sample Input: 'customers'

customer_idfirst_namelast_namebilling_address
001JohnDoe123 Anywhere St, Amsterdam, Netherlands
002JaneSmith456 Another Rd, New York, USA
003SamLee789 Somewhere Ave, Rotterdam, Netherlands
004MikeTaylor321 Everywhere Blvd, London, UK
005EmmaBrown654 Nowhere Ln, Utrecht, Netherlands

Sample Output:

customer_idfirst_namelast_namebilling_address
001JohnDoe123 Anywhere St, Amsterdam, Netherlands
003SamLee789 Somewhere Ave, Rotterdam, Netherlands
005EmmaBrown654 Nowhere Ln, Utrecht, Netherlands

Answer:


This SQL query uses the keyword to filter out all records where the ends with "Netherlands". The '%' before 'Netherlands' is a wildcard character that matches any sequence of characters. As a result, all customers that have a billing address in Netherlands are returned.

SQL Question 7: What's a foreign key?

A foreign key is a column or group of columns in a table that refers to the primary key in another table. The foreign key constraint helps maintain referential integrity between the two tables. The table with the foreign key is called the child table, while the table with the candidate key is called the parent or referenced table.

For example, consider a database with two tables: and customer_idcustomer_idcustomer_id` column in Adyen customers table.

SQL Question 8: Track Total Transactions and Total Amount per Customer

Adyen is a payments company that processes transactions for businesses. Given two tables - and , you are asked to write a SQL query that returns each customer's name, total number of transactions and total amount spent. Assume each customer can have multiple transactions but each transaction can be associated with only one customer.

Consider the following tables:

Example Input:
transaction_idcustomer_idamounttransaction_date
100150115001/20/2022
100250220002/15/2022
100350110001/21/2022
100450325002/10/2022
10055017501/20/2022
Example Input:
customer_idname
501John
502Sara
503Daniel
504Monica

Answer:


This SQL query joins the and tables on the . is then used to group the data by customer. The aggregate functions and are used to calculate the total number of transactions and the total amount spent by each customer, respectively. The clause is used to sort the data first by total transactions in descending order, and then by total amount in descending order in case of a tie.

Since joins come up so often during SQL interviews, try this interactive Snapchat Join SQL question: Snapchat Join SQL question

SQL Question 9: Average Payment Volume per Hour

Adyen is a global payment processor. A common need for such a company would be to analyze payment volume over certain periods. Given a table of transactions, can you write a SQL query that returns the average payment volume per hour of the day?

Assume you are given a table, , with the following schema:

Example Input:
transaction_idtimestamppayment_volume
12022-05-05 03:00:00350.00
22022-05-05 04:15:00240.00
32022-05-05 04:30:00150.00
42022-05-06 05:00:00560.00
52022-05-06 05:05:00300.00

You are expected to produce output in the following format, where is a 24-hour format and is rounded to two decimal places:

Example Output:
hour_of_dayavg_payment_volume
3350.00
4195.00
5430.00

Answer:


This query first extracts the hour of the day from the timestamp for each transaction. It then groups by the hour of the day and calculates the average payment volume per hour. The result is ordered by to make the output intuitive.

Adyen SQL Interview Tips

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. In addition to solving the above Adyen SQL interview questions, you should also solve the 200+ SQL exercises on DataLemur which come from companies like FAANG (FB, Apple, Amazon, Netflix, Google). DataLemur SQL Interview Questions

Each SQL question has multiple hints, fully explained answers along with a discussion board to see how others solved it and crucially, there's an interactive coding environment so you can right in the browser run your SQL query and have it executed.

To prep for the Adyen SQL interview it is also helpful to practice SQL questions from other tech companies like:

In case your SQL query skills are weak, don't worry about going right into solving questions – strengthen your SQL foundations with this DataLemur SQL Tutorial.

DataLemur SQL Tutorial for Data Science

This tutorial covers SQL concepts such as handling dates and WHERE vs. HAVING – both of which come up often in Adyen SQL assessments.

Adyen Data Science Interview Tips

What Do Adyen Data Science Interviews Cover?

In addition to SQL interview questions, the other question categories covered in the Adyen Data Science Interview are:

Adyen Data Scientist

How To Prepare for Adyen Data Science Interviews?

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

  • 201 interview questions taken from FAANG, tech startups, and Wall Street
  • a refresher covering Product Analytics, SQL & ML
  • over 900+ 5-star reviews on Amazon

Ace the DS Interview