Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
FAANG SQL QUERIES PART - 2
166 students
Last updated 1/2025
English

What you'll learn

  • SOLVE SQL QUERIES
  • FAANG SQL
  • SQL QUERIES ASKED IN PRODUCT BASED
  • HOW TO SOLVE SQL QUERIES STEP BY STEP

Course content

1 section12 lectures1h 3m total length
  • 1_Pharmacy Analytics (Part 3) [CVS Health SQL Interview Question]9:14
  • 2_Pharmacy Analytics (Part 4) [CVS Health SQL Interview Question]5:25

    Identify the top two drugs sold per manufacturer in CVS Health's pharmacy sales using a rank function partitioned by manufacturer and ordered by units sold.

  • 3_Y-on-Y Growth Rate [Wayfair SQL Interview Question]10:13
  • 4_Ad Campaign ROAS [Google SQL Interview Question2:41

    Compute roas for each advertiser by summing revenue and spend across campaigns, computing revenue per spend, rounding to two decimals, and sorting by advertiser_id.

  • 5_Trade In Payouts [Apple SQL Interview Question]3:05
  • 6_Cumulative Purchases by Product Type [Amazon SQL Interview Question2:54
  • 7_Repeat Purchases on Multiple Days [Stitch Fix SQL Interview Question]4:18
  • 8_Subject Matter Experts [Accenture SQL Interview Question]5:51
  • 9_User Session Activity [Twitter SQL Interview Question]5:42

    Learn to rank users by total session durations in minutes per session type using window functions on the Twitter sessions table, outputting user_id, session_type, and the ranking.

  • 10_ApplePay Volume4:20
  • 11_Histogram of Users and Purchases [Walmart SQL Interview Question]6:07

    Identify each user's most recent transaction date and count products purchased on that date using SQL, a per-user max date, inner join, and group by user ID to form histogram.

  • 12_Unique Money Transfer Relationships [PayPal SQL Interview Question]3:18

Requirements

  • Basic SQL Knowledge

Description

Solving SQL queries for FAANG (Facebook, Amazon, Apple, Netflix, Google) interviews requires a solid understanding of SQL fundamentals, along with the ability to approach problems efficiently. Here's a step-by-step guide on how to tackle FAANG SQL queries:

1. Understand the Problem Clearly

  • Read the problem statement carefully: Understand what data is required and what results need to be produced.

  • Look for key elements: Tables, columns, conditions, and any grouping/aggregation that might be necessary.

  • Clarify edge cases: If the problem is ambiguous, ask questions to clarify details (e.g., handling NULLs, ties in ranking, etc.).

2. Identify the Relevant Tables and Columns

  • Determine the main table: The one from which you’ll mostly pull data.

  • Look at any relationships: Identify any JOINs between multiple tables if needed.

  • Check for required columns: Know exactly which columns you’ll need for your SELECT statement.

3. Choose the Right SQL Clauses

  • SELECT: Specify which columns you need.

  • FROM: Define the tables you are querying.

  • WHERE: Add filters based on the conditions specified in the problem.

  • JOIN: Use if you need to combine data from multiple tables.

  • GROUP BY: When aggregating data, group by the relevant columns.

  • HAVING: Use to filter grouped results (applies after aggregation).

  • ORDER BY: Sort the results if needed.

  • LIMIT: To restrict the number of rows returned (useful for ranking, top-N queries, etc.).

4. Write the Query in Steps

  • Start simple: Begin with a basic query that selects all the necessary columns from the relevant table(s).

  • Apply filters: Add the WHERE clause to narrow down the dataset.

  • Add aggregation (if required): Use COUNT, SUM, AVG, etc., along with GROUP BY.

  • Optimize: If the query is too slow or complex, look for optimization opportunities (e.g., using indexes, eliminating unnecessary JOINs, or using subqueries).

5. Handle Advanced Concepts

  • Subqueries: For complex filtering or when the result depends on a calculation based on other records.

  • Window Functions: Useful for ranking, calculating running totals, moving averages, etc. Functions like ROW_NUMBER(), RANK(), and OVER() are frequently used in FAANG interviews.

  • Common Table Expressions (CTEs): Used to simplify complex queries and improve readability.

  • Joins: Be familiar with different types of joins (INNER, LEFT, RIGHT, FULL OUTER) and when to use them.

  • Self Joins: Use when you need to join a table with itself (e.g., employee-manager relationships).

6. Test with Sample Data

  • Before finalizing your query, check how it behaves with sample data, and test for edge cases.

  • Be mindful of NULL values, duplicates, and large datasets.

7. Explain Your Thought Process

  • During an interview, explain your approach clearly. Discuss why you chose specific SQL constructs, like joins, groupings, and aggregations.

  • If necessary, walk through the problem-solving steps and any trade-offs you made.

Who this course is for:

  • SQL Professionals, Data Analysts, Data Engineers