logo

10 Marathon Digital SQL Interview Questions (Updated 2024)

Updated on

March 3, 2024

At Marathon Digital Holdings, SQL is used often for analyzing cryptocurrency mining data and optimizing operational efficiency in the company's blockchain network. So, it shouldn't surprise you that Marathon Digital almost always asks SQL problems during interviews for Data Analyst, Data Science, and BI jobs.

Thus, to help you prepare for the Marathon Digital SQL interview, here’s 10 Marathon Digital Holdings SQL interview questions – how many can you solve?

10 Marathon Digital SQL Interview Questions

SQL Question 1: Identify most engaging users in Marathon Digital

Marathon Digital is a blockchain technology company offering cloud-based Bitcoin mining services. One of the key metrics for the company is the accumulated hash power each user brings to the network, as it identifies the users who are supporting the network's security and transaction verification process most significantly.

Please write a SQL query that identifies the top 5 users by accumulated hash power in the past 30 days.

Example Input:
user_idactivity_datehash_power_GHs
12022-06-01720
12022-06-15500
22022-06-25880
32022-06-02450
32022-06-18350
42022-06-10500
52022-06-20400
52022-06-25300
Example Output:
user_idtotal_hash_power_GHs
11220
2880
4500
5700
3800

Answer:


This query groups all activity by user_id, sums up the total hash power for each user, and then orders the users in descending order by their total hash power, giving us the users who have contributed the most hash power in the last 30 days. The clause ensures that we only see the top 5 of these VIP users.

To work on a similar customer analytics SQL question where you can solve it interactively and have your SQL query instantly executed, try this Walmart Labs SQL Interview Question: Walmart SQL Interview Question

SQL Question 2: Analyze Mining Data

Marathon Digital is a Bitcoin mining company. You're given a table that contains information about daily mining activities over a period of time.

The table has the following columns:

  • id (integer): Unique identifier.
  • mine_date (date): The day of mining.
  • amount_mined (float): The amount of Bitcoin mined on that day.
  • power_consumed (float). The amount of power consumed on that day.

The company wants to analyze their mining efficiency over the past 7 days, averaged over each day.

Example Input:
idmine_dateamount_minedpower_consumed
101/01/202210.5100
201/02/202210120
301/03/202210.2130
401/04/202211150
501/05/202210.8140
601/06/20229.8130
701/07/202210.2160
801/08/202210.5140
901/09/202210.3130
Example Output:
mine_dateefficiency
01/07/20220.067
01/08/20220.069
01/09/20220.070

Answer:


This query creates a sliding window of 7 days (6 days preceding and the current day). Within this window, it calculates the average daily mining efficiency by dividing the total amount of bitcoin mined by the total power consumed. Finally, the query restricts the output to the 7th, 8th, and 9th of January.

To practice a related window function SQL problem on DataLemur's free interactive SQL code editor, try this Google SQL Interview Question: Google SQL Interview Question

SQL Question 3: What are the ACID properties in a DBMS?

A DBMS (database management system), in order to ensure transactions are relaible and correct, tries to mantain the following ACID properties: Atomicity, Consistency, Isolation, and Durability

Here is what each of the ACID properties stands for:

Atomicity: ensures that a transaction is either completed in its entirety, or not completed at all. If a transaction fails halfway, the database does a rollback on the commit.

Consistency: ensures that a transaction will only be completed if adheres to the constraints defined in the database of the DB.

Isolation: ensures that concurrent transactions are isolated from each one another, so that the changes made by one transaction cannot be seen by a 2nd transaction until the 1st transaction is done.

**Durability: ** ensures that once a transaction has been committed, the database permanently stores the results in the DB.

As you can see, it's pretty important for Marathon Digital's data systems to be ACID compliant, else they'll be a big problem for their customers!

Marathon Digital Holdings SQL Interview Questions

SQL Question 4: Analyzing Customer Mining Statistics

Given a table of mining statistics of the customers from Marathon Digital, we want to query the database to identify customers whose total mined bitcoin count is higher than a certain threshold and who have been mining for more than a specific duration. More specifically, we want to find customers who have mined more than 5 bitcoins and have been mining for 3 or more years.

The table has the following format:

Example Input:
customer_idstart_datetotal_btc_mined
100101/02/201910
100204/08/20184
100511/13/20178
101006/23/20192
102302/08/20189

We will use a PostgreSQL query to filter out the customer records that meet our criteria.

Answer:


This query returns all the field values of the customers who have mined more than 5 bit coins and have been mining for more than 3 years. The AGE function is used to calculate the time interval between the current date and the start mining date. The DATE_PART function is then used to extract the quantity of years from this interval, allowing the database to filter customer records based on the specified conditions. The WHERE clause is then used to specify these conditions.

SQL Question 5: How do and differ when it comes to ranking rows in a result set?

While both and are used to rank rows, the key difference is in how they deal with ties.

RANK(): When there's a tie, leaves a gap in the ranking. For example, if three rows are tied for 2nd place, the RANK() function will assign a rank of 2 to the first of these rows, a rank of 3 to the 2nd row in the tie, and a rank of 4 to the the 3rd tie.

DENSE_RANK(): For ties, does not leave a gap in the ranking. Instead, it assigns the same rank to all tied rows, and then makes the next row 1 bigger. Confusing, I know, but here's an example to make it more clear: if three rows are tied for 3rd place, the function will assign a rank of 3 to all three rows, and then assign a rank of 4 to the next row.

Suppose we had data on how many deals different salespeople at Marathon Digital:


To rank these salespeople, we could execute the following query:


The result of this query would be:

namedeals_closedrankdense_rank
Akash5011
Brittany5021
Carlos4032
Dave4043
Eve3053
Farhad1064

As you can see, the function assigns a rank of 1 to the first row (Akash), a rank of 2 to the second row (Brittany), and so on. In contrast, the , gives both Akash and Brittany a rank of 1, since they are tied, then moves on to rank 2 for Carlos.

SQL Question 6: Compute the Average Hash Rate Per Mining Device

Marathon Digital Holdings is a digital asset technology company that mines cryptocurrencies, with a focus on the blockchain ecosystem and the generation of digital assets. Based on their business, a potential interview question may revolve around calculating the average hash rate (the speed of mining operations) on their various mining devices.

You are provided with a table, , which logs the hash rate per device at different times.

Example Input:
log_iddevice_idlog_timehash_rate
1100101/01/2022 01:00:005500.45
2100201/01/2022 02:00:006453.84
3100101/01/2022 02:00:005604.88
4100301/01/2022 03:00:006032.21
5100201/01/2022 03:00:006570.60

The task is to find the average hash rate for each device across all log times.

Example Output:
device_idaverage_hash_rate
10015552.66
10026512.22
10036032.21

Answer:


This query groups the data by each device and calculates the average hash rate for that device over all log times. It uses the aggregate function on the hash_rate column to find the average.

To practice a very similar question try this interactive Google Odd and Even Measurements Question which is similar for using statistical calculations on device data or this Amazon Server Utilization Time Question which is similar for calculating total computational time.

SQL Question 7: What is the difference between a primary key and a foreign key?

To explain the difference between a primary key and foreign key, let's inspect employee data from Marathon Digital's HR database:

:

+------------+------------+------------+------------+ | employee_id| first_name | last_name | manager_id | +------------+------------+------------+------------+ | 1 | Aubrey | Graham | 3 | | 2 | Marshal | Mathers | 3 | | 3 | Dwayne | Carter | 4 | | 4 | Shawn | Carter | | +------------+------------+------------+------------+

In this table, could be a primary key. It is unique for each row in the table and cannot contain null values.

could be a foreign key. It references the of the manager of each employee in the table, establishing a relationship between the employees and their managers. This foreign key allows you to easily query the table to find out who a specific employee's manager is, or to find out which employees report to a specific manager.

It is also possible for a table to have multiple foreign keys that reference different primary keys in other tables. For example, the table could have additional foreign keys for the of the department where each employee works, and the l of the location where each employee is based.

SQL Question 8: Aggregate Power Consumption

All miners in Marathon Digital are assigned an unique ID and regularly report back the power consumption (in kilowatts). As an SQL engineer, can you write a query to find the total power consumption for each miner for a given period of time?

Example Input:

miner_idminer_name
1001MinerA
1002MinerB
1003MinerC

Example Input:

pc_idminer_idreported_datetimepower_kw
2001100106/08/2022 00:00:0050
2002100106/10/2022 00:00:0075
2003100206/18/2022 00:00:00100
2004100207/26/2022 00:00:0080
2005100307/05/2022 00:00:0060

Example Output:

minertotal_power_kw
MinerA125
MinerB180
MinerC60

Answer:

Your SQL query would look like this for PostgreSQL.


In this query, we first join the two tables and on their shared column . After this join operation, every row will contain the information about miner and its power consumption. We then group rows by . For each group, we compute the sum of , which represents the total power consumption for the corresponding miner. Finally, we order the results by in descending order. This way, we can easily find out which miners consume the most power.

SQL Question 9: Finding Specific Customers

You are working as a data analyst at Marathon Digital, a global cryptocurrency mining company. The marketing team wants to send a promotional email to all customers whose email addresses contain the string "bitcoin". Write a SQL query to find the details of all such customers from the company's customers' record.

Example Input:

User_IDFirst_NameEmailJoined_Date
102Johnjohn@gmail.com2021-01-12
103SamanthasuperBitcoin@gmail.com2020-10-07
104Davecool_dave@yahoo.com2022-02-26
105Rachelrachel_bitcoin@yahoo.com2019-07-14
106Laylalayla@hotmail.com2018-09-15

Example Output:

User_IDFirst_NameEmailJoined_Date
103SamanthasuperBitcoin@gmail.com2020-10-07
105Rachelrachel_bitcoin@yahoo.com2019-07-14

Answer:


This SQL query filters the "customers" table to find rows where the "Email" field contains the string "bitcoin". The "%" symbol in the LIKE clause is a wildcard character that matches any sequence of characters. This query will return all customers whose email addresses contain the term "bitcoin".

SQL Question 10: What does it mean to use a UNIQUE constraint in a database?

A UNIQUE constraint ensures that all values in a column are different. It is often used in conjunction with other constraints, such as NOT NULL, to ensure that the data meets certain conditions.

For example, if you had Marathon Digital sales leads data stored in a database, here's some constraints you'd use:


In this example, the UNIQUE constraint is applied to the "email" and "phone" fields to ensure that each Marathon Digital lead has a unique email address and phone number. This helps to ensure the integrity of the data in the database and prevents errors that could occur if two leads had the same email address or phone number.

Marathon Digital SQL Interview Tips

The best way to prepare for a Marathon Digital SQL interview is to practice, practice, practice. Besides solving the earlier Marathon Digital SQL interview questions, you should also solve the 200+ SQL questions on DataLemur which come from companies like FAANG and tech startups. DataLemur SQL and Data Science Interview Questions

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

To prep for the Marathon Digital SQL interview you can also be helpful to practice interview questions from other tech companies like:

However, if your SQL skills are weak, forget about diving straight into solving questions – go learn SQL with this free SQL tutorial.

Interactive SQL tutorial

This tutorial covers topics including turning a subquery into a CTE and 4 types of JOINS – both of these show up frequently during SQL job interviews at Marathon Digital.

Marathon Digital Holdings Data Science Interview Tips

What Do Marathon Digital Data Science Interviews Cover?

Beyond writing SQL queries, the other types of questions to practice for the Marathon Digital Data Science Interview are:

Marathon Digital Data Scientist

How To Prepare for Marathon Digital Data Science Interviews?

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

  • 201 Interview Questions from Microsoft, Amazon & startups
  • A Refresher covering Stats, ML, & Data Case Studies
  • Great Reviews (900+ 5-star reviews on Amazon)

Ace the DS Interview