10 Marqeta SQL Interview Questions (Updated 2025)

Updated on

March 11, 2025

At Marqeta, SQL is used across the company for analyzing payment transactions and managing customer datasets in the fintech industry. That's why Marqeta almost always asks SQL questions during interviews for Data Science and Data Engineering positions.

Thus, to help you practice for the Marqeta SQL interview, here’s 10 Marqeta SQL interview questions – can you solve them?

10 Marqeta SQL Interview Questions

SQL Question 1: Identify Most Active Cardholders

Marqeta, a global modern card issuing platform, has a number of individual cardholders who make transactions using their cards. Your goal as a Data Analyst is to write a SQL Query to identify the most active cardholders in terms of transaction frequency. Assume high activity to be more than 30 transactions per month.

To solve this, we have the following table named "transactions".

transactions Example Input:
transaction_idcardholder_idtransaction_datetransaction_amount
156723106/07/2022 00:00:00500
254634206/12/2022 00:00:00850
356423106/14/2022 00:00:00300
489241507/20/2022 00:00:00750
501134207/24/2022 00:00:00450

Answer:

Here is an SQL PostgreSQL query to calculate the most active users by transaction count in a month.

SELECT cardholder_id, DATE_TRUNC('month',transaction_date) as month, COUNT(transaction_id) as transaction_count FROM transactions GROUP BY cardholder_id, month HAVING COUNT(transaction_id) > 30 ORDER BY transaction_count DESC ;

This query will group transactions by cardholder_id and month and count the number of transactions per cardholder per month. Then it filters out cardholders who made more than 30 transactions in a single month and returns them in descending order based on frequency of transactions.

Note: This is a hypothetical scenario and the threshold of 30 transactions is arbitrary. Calling a user who makes more than 30 transactions a "power user" might not apply in many situations and doesn't account for factors like the total amount of money transacted. For instance, a user who made 31 transactions totaling 310isarguablylessofa"poweruser"thansomeonewhomade1transactionworth310 is arguably less of a "power user" than someone who made 1 transaction worth 3000. Adjust the threshold and the features such as transaction_amount based on your specific needs.

To practice another SQL customer analytics question where you can code right in the browser and have your SQL solution instantly executed, try this Walmart SQL Interview Question: Walmart Labs SQL Interview Question

SQL Question 2: Average Daily Transactions Per Card

Suppose you work for Marqeta, a company that provides card issuance and digital payment solutions and services. You've been tasked with analyzing transaction data to understand card usage patterns. Specifically, you've been asked to write a SQL query that computes the average number of transactions by card on a daily basis for each user.

For data, you have two main tables: cards and transactions

cards example input:

card_iduser_id
1A
2A
3B
4B
5C

transactions example input:

txn_idcard_idtxn_date
10112022-08-01
10212022-08-01
10322022-08-02
10412022-08-03
10532022-08-01
10642022-08-01
10752022-08-01
10832022-08-02
10942022-08-02
11022022-08-03

Answer:

To compute the average daily transactions per card for each user, you can use the PostgreSQL window function. Here's an example query:

SELECT cards.user_id, COUNT(transactions.txn_id) OVER(PARTITION BY transactions.card_id, DATE(transactions.txn_date)) as daily_txns, AVG(count) OVER(PARTITION BY cards.user_id) as average_daily_txns FROM transactions JOIN cards ON transactions.card_id = cards.card_id ORDER BY cards.user_id

This query first joins the transactions and cards table using the card_id. It then groups by card_id and txn_date to count the number of transactions each card has on every unique day (daily_txns). Finally, it computes the average number of these daily transactions for each user by using the AVG() function over user_id. The ORDER BY clause is used to sort the output by user_id.

p.s. Window functions show up pretty often during SQL interviews, so practice the 27+ window function questions on DataLemur

DataLemur Window Function SQL Questions

SQL Question 3: How do you locate records in one table that are absent from another?

To discover records in one table that are not present in another, you can utilize a LEFT JOIN and filter out any NULL values in the right-side table.

For example, say you had a table of Marqeta customers and a 2nd table of all purchases made with Marqeta. To find all customers who did not make a purchase, you'd use the following LEFT JOIN

SELECT customers.* FROM customers LEFT JOIN purchases ON customers.id = purchases.customer_id WHERE purchases.id IS NULL;

This query returns all rows from the customers table, along with any matching rows from the purchases table. If there is no matching row in the purchases table, NULL values will be returned for all of the right table's columns. The WHERE clause then filters out any rows where the purchases.id column is NULL, leaving only customers who have not made a purchase.

Marqeta SQL Interview Questions

SQL Question 4: Designing Database for Transaction Analysis at Marqeta

Marqeta is a modern payment platform, enabling companies to create, manage, and optimize card-based payments. Imagine you are a part of the data engineering team at Marqeta. Your task is to design a database schema for tracking individual card transactions and retrieving aggregate expenditure for each user on a monthly basis.

Considerations:

  • Each transaction involves a card that is owned by a specific user.
  • Each card has a unique card_id, and each user has a unique user_id.
  • Each transaction has a transaction_id, transaction_date, and an amount.

How would you design your tables, relationships, and which columns belong to which tables, considering performance for an SQL query that retrieves a monthly breakdown of transactions per user?

Here are some sample transactions:

transactions Example Input:
transaction_idcard_idtransaction_dateamount
1001200106/08/2022 00:00:0050
1002200206/10/2022 00:00:00120
1003200306/18/2022 00:00:0075
1004200107/26/2022 00:00:00100
1005200207/05/2022 00:00:0080
cards Example Input:
card_iduser_id
20013001
20023002
20033001

Answer:

Get a report of total expenditure for each user per month:

SELECT date_trunc('month', t.transaction_date) as mth, c.user_id, sum(t.amount) as total_amount FROM transactions t INNER JOIN cards c on t.card_id = c.card_id GROUP BY mth, c.user_id ORDER BY mth, c.user_id;

This query gives a breakdown of total monthly transactions for each user. It starts by truncating the transaction_date to retain only the month and year. It then groups the results by this date and user_id. 'Sum' calculates the total transaction amount per user per month. It gives the total expenditure for each user on Marqeta's platform each month.

SQL Question 5: What is database denormalization?

Database denormalization is when you add redundancy to a database, and break typical normalization rules (codified by the 1st, 2nd, 3rd normal forms).

Denormalization is typically used to improve the performance of a database, particularly when the database is being for OLAP (Online Analytical Processing) purposes. By denormalizing a database, you can reduce the number of joins that are required to retrieve data, which can greatly improve the speed of queries since joins are costly and slow. However, denormalization can also introduce some problems, such as increased data redundancy and the need for more complex update and delete operations since data has been duplicated into multiple tables.

In general, denormalization should be used with caution and only after careful consideration of the trade-offs involved. It's typically better to start with a well-normalized database design then denormalize only if your database isn't scaling as well as you want.

SQL Question 6: Filter Customer Records

As a data analyst at Marqeta, your manager asked you to filter down the customer data to identify specific customers. Write a SQL query to find all customers who live in California and either have made more than 10 transactions or have spent over $2000 in total.

Here are your tables:

customers Example Input:
customer_idfirst_namelast_namestate
001JohnDoeCalifornia
002JaneSmithNew York
003BobJohnsonCalifornia
004AliceDavisCalifornia
transactions Example Input:
transaction_idcustomer_idamounttransaction_date
00010015002022-09-01
00020017002022-09-02
00030028002022-09-02
00040032502022-09-03
000500318502022-09-04
000600412002022-09-05
000700418002022-09-06

Answer:

Here is your PostgreSQL solution:

SELECT c.customer_id, c.first_name, c.last_name, c.state, COUNT(t.transaction_id) AS transactions, SUM(t.amount) AS total_spent FROM customers c JOIN transactions t ON c.customer_id = t.customer_id WHERE c.state = 'California' GROUP BY c.customer_id HAVING COUNT(t.transaction_id) > 10 OR SUM(t.amount) > 2000;

This solution first joins the customers table with the transactions table on the customer_id column. Then, it filters to only customers in California. Finally, it counts the number of transactions and sums the amounts spent for each customer, filtering to only those who have made more than 10 transactions or have spent over $2000.

SQL Question 7: What is the difference between cross join and natural join?

A cross join is a type of JOIN operation in SQL that creates a new table by combining each row from the first table with every row from the second table. It is also known as a cartesian join.

For example, say you worked on the Marketing Analytics team at Marqeta, and needed to understand what advertising copy (text) goes best with what advertising creative (the photo that gets posted with the advertisement copy).

Here is an example of a cross-join between a table of ad_copy and a table of ad_creative:

SELECT ad_copy.copy AS ad_copy, ad_creative.image_url AS ad_creative FROM ad_copy CROSS JOIN ad_creative;

A natural join, on the other hand, is a type of JOIN that combines rows from two or more tables based on their common columns. It is called a "natural" join because it is based on the natural relationship that exists between the common columns in the tables being joined.

For an example of each one, say you had sales data exported from Marqeta's Salesforce CRM stored in a datawarehouse which had two tables: sales and marqeta_customers.

An INNER JOIN (which is a type of natural join) combines the two tables on the common customer_id field

SELECT * FROM sales INNER JOIN marqeta_customers ON sales.customer_id = marqeta_customers.id

This query will return rows from the sales and marqeta_customers tables that have matching customer id values. Only rows with matching customer_id values will be included in the results.

One main difference between cross joins and natural joins is that cross joins do not require any common columns between the tables being joined, while natural joins do. Another difference is that cross joins can create very large tables if the input tables have a large number of rows, while natural joins will only return a table with the number of rows equal to the number of matching rows in the input tables.

SQL Question 8: Filtering Client Records by Address

As part of Marqeta's internal audit system, they are interested in identifying all clients whose address contains the word "Avenue". Using the clients table provided below, write a SQL query to return all records where the client's address matches this criterion.

clients Example Input:
client_idclient_nameaddress
101James Smith123 Main Street
102Jessica Johnson456 Maple Avenue
103Roger Davis789 Oak Street
104Laura Wilson1012 Pine Avenue
105Bob Thomas345 Walnut Street

Answer:

SELECT * FROM clients WHERE address LIKE '%Avenue%';

This SQL query uses the LIKE keyword within the WHERE clause to filter the records from the clients table. Any record where the 'address' field contains the string "Avenue" will be returned. The '%' character is a wildcard that matches any number of characters, so it allows for the matching string to be at any position within the address field. The result will be a table containing all client records where the address contains "Avenue".

Please note that LIKE queries are case sensitive in PostgreSQL, so be careful when matching case-sensitive patterns.

SQL Question 9: Find the Top Revenue Generating Customers

Given two tables, customers and transactions, the task is to write a SQL query that returns a list of top 5 customers who generated the highest revenue for Marqeta.

customers Example Input:

cust_idfirst_namelast_namesign_up_datebalance
101TomHolland2018-03-17500
102JasminePaul2016-02-262000
103MorganFreeman2015-01-0110000
104JamesCameron2019-12-31350
105AmeliaVega2018-03-024500

transactions Example Input:

trans_idcust_idtrans_dateproduct_idamount
80011012021-06-01201300
80021022021-06-20202700
80031032021-07-17203500
80041042021-08-31204700
80051052021-10-10205650

Answer:

SELECT c.first_name, c.last_name, SUM(t.amount) as total_revenue FROM customers c JOIN transactions t ON c.cust_id = t.cust_id GROUP BY c.cust_id ORDER BY total_revenue DESC LIMIT 5;

In this query, we're using a JOIN statement to combine the customers and transactions tables based on cust_id. We're then using an aggregation function (SUM) to calculate the total revenue for each customer (total_revenue). The results are ordered in descending order of total_revenue and limited to the top 5 customers.

Since join questions come up routinely during SQL interviews, practice this Snapchat JOIN SQL interview question: Snapchat SQL Interview question using JOINS

SQL Question 10: Name the different types of joins in SQL. What does each one do?

Using a join in SQL, you can retrieve data from multiple tables and merge the results into a single table.

In SQL, there are four distinct types of JOINs. To demonstrate each kind, Imagine you had two database tables: an Advertising_Campaigns table that contains data on Google Ads keywords and their bid amounts, and a Sales table with information on product sales and the Google Ads keywords that drove those sales.

  • INNER JOIN: An INNER JOIN retrieves rows from both tables where there is a match in the shared key or keys. For example, an INNER JOIN between the Advertising_Campaigns table and the Sales table could be performed using the keyword column as the shared key. This would retrieve only the rows where the keyword in the Advertising_Campaigns table matches the keyword in the Sales table.

  • LEFT JOIN: A LEFT JOIN retrieves all rows from the left table (in this case, the Advertising_Campaigns table) and any matching rows from the right table (the Sales table). If there is no match in the right table, NULL values will be returned for the right table's columns.

  • RIGHT JOIN: A RIGHT JOIN retrieves all rows from the right table (in this case, the Sales table) and any matching rows from the left table (the Advertising_Campaigns table). If there is no match in the left table, NULL values will be returned for the left table's columns.

  • FULL OUTER JOIN: A FULL OUTER JOIN retrieves all rows from both tables, regardless of whether there is a match in the shared key or keys. If there is no match, NULL values will be returned for the columns of the non-matching table.

Marqeta SQL Interview Tips

The key to acing a Marqeta SQL interview is to practice, practice, and then practice some more! Beyond just solving the earlier Marqeta SQL interview questions, you should also solve the 200+ SQL coding questions which come from companies like FAANG and tech startups. DataLemur SQL Interview Questions

Each DataLemur SQL question has multiple hints, detailed solutions and crucially, there's an online SQL coding environment so you can right in the browser run your query and have it checked.

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

However, if your SQL coding skills are weak, forget about diving straight into solving questions – strengthen your SQL foundations with this free SQL for Data Analytics course.

DataLemur SQL Course

This tutorial covers things like RANK() window functions and UNION – both of these pop up often during SQL job interviews at Marqeta.

Marqeta Data Science Interview Tips

What Do Marqeta Data Science Interviews Cover?

In addition to SQL query questions, the other topics tested in the Marqeta Data Science Interview are:

Marqeta Data Scientist

How To Prepare for Marqeta Data Science Interviews?

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

  • 201 Interview Questions from Google, Microsoft & tech startups
  • A Crash Course covering Stats, ML, & Data Case Studies
  • Amazing Reviews (900+ reviews, 4.5-star rating)

Ace the DS Interview