3 Apple SQL Interview Questions To Practice (From Recent Apple Technical Interviews)

3 Apple SQL Interview Questions To Practice (From Recent Apple Technical Interviews)

If you've got an upcoming SQL interview at Apple, as part of a Data Science, Data Analyst, or Data Engineering job interview at Apple, you've got to practice these 3 real Apple SQL Interview Questions!

SQL Question 1: AirPod Percentage After Buying iPhone

Write a SQL query to determine the percentage of buyers who bought AirPods directly after they bought iPhones.

In the example above, we output 50% because only user 101 bought AirPods after buying an iPhone. We can't count customer 301 since they bought an iPad in between their iPhone and AirPods.

To practice this question yourself, subscribe to DataLemur Premium and start solving this problem directly in the browser:

Apple SQL Interview Question on DataLemur.com

Solution:

WITH cte AS (
  SELECT
    customer_id,
    STRING_AGG(product_name, ',' ORDER BY transaction_timestamp) AS products
  FROM transactions
  GROUP BY 1
)

SELECT
  ROUND(100.0 * SUM(CASE WHEN products LIKE '%iPhone,AirPods%' THEN 1 END) / COUNT(DISTINCT customer_id), 0) AS follow_up_percentage
FROM transactions
JOIN cte
  USING(customer_id)        

SQL Question 2: Difference Between WHERE vs. HAVING?

This is an easy Apple SQL Interview question, meant for Business Analysts and interns. HAVING is similar to WHERE, except it's used to filter groups of rows (that are the result of the GROUP BY) clause.

Here's a great infographic to help:

WHERE vs. HAVING by Saloni

SQL Question 3: Apple Device Trade-In Analysis

Apple has a trade-in program where their customers can return the old iPhone device to Apple and Apple gives the customers the trade-in value (known as payout) of the device in cash.

For each store, write a SQL query of the total revenue from the trade-in. Order the result by the descending order.

Apple Device Trade-In SQL Analysis Question


Want to practice more Apple SQL Interview Questions?

You'll find more Apple SQL interview questions on DataLemur's blog post 10 Apple SQL Interview Questions which is a MUST READ in case you've got an upcoming Data Science/Data Engineering interview at Apple.

It can also look at Facebook SQL Questions & Amazon SQL Interview Questions for additional practice, because let's face it – FAANG does technical interviews in a similar-ish way!


Dr. Franco Arda

Partner |?Data Scientist

1 年

Nick Singh ???? Wow, your website rocks. Your SQL explanations are amazing!

回复
Nick Singh ????

Founder of DataLemur.com (Ace SQL Interviews) ? Best-Selling Author of Ace the Data Science Interview ? Ex-Facebook ? LinkedIn Top Voice ? 175,000+ Nerds Follow Me on LinkedIn for Data/SQL/Career tips!

1 年

tricky Apple SQL Interview Questions on this one!

要查看或添加评论,请登录

DataLemur ?? (Ace the SQL & Data Interview)的更多文章

社区洞察

其他会员也浏览了