DataLemur ๐Ÿ’ (Ace the SQL & Data Interview)

DataLemur ๐Ÿ’ (Ace the SQL & Data Interview)

Information Services

San Francisco, California 41,908 followers

Practice real FAANG SQL & Data Interview questions! Made by Nick Singh, Best-Selling Author of Ace the Data Interview!

About us

Hi, I'm Nick Singh, the creator of DataLemur! I used to write SQL queries and run A/B tests all day at Facebook, and before that, wrote Python on Google Nest's Data Infrastructure Team. I know first-hand how difficult Data Science, Data Analyst, & Data Engineering interviews can be. While my best-selling book, Ace the Data Science Interview, has successfully helped 16,000+ readers prepare for the Statistics, ML, and Business-Sense portions of data interviews, readers kept asking for a more interactive way to practice the SQL questions from the book. That's why I made DataLemur, a SQL & Data Analytics interview platform for the data community! Happy practicing: https://datalemur.com/

Website
http://datalemur.com/
Industry
Information Services
Company size
2-10 employees
Headquarters
San Francisco, California
Type
Privately Held

Locations

Employees at DataLemur ๐Ÿ’ (Ace the SQL & Data Interview)

Updates

  • SQL Interviews LOVE to test you on Window Functions. Hereโ€™s the 7 most popular window functions & some real SQL interview questions to practice these commands ๐Ÿ‘‡ ๐Ÿ• ๐Œ๐จ๐ฌ๐ญ ๐“๐ž๐ฌ๐ญ๐ž๐ ๐–๐ข๐ง๐๐จ๐ฐ ๐…๐ฎ๐ง๐œ๐ญ๐ข๐จ๐ง๐ฌ * RANK() - gives a rank to each row in a partition based on a specified column or value * DENSE_RANK() - gives a rank to each row, but DOESN'T skip rank values * ROW_NUMBER() - gives a unique integer to each row in a partition based on the order of the rows * LEAD() - retrieves a value from a subsequent row in a partition based on a specified column or expression * LAG() - retrieves a value from a previous row in a partition based on a specified column or expression * NTH_VALUE() - retrieves the nth value in a partition Now, letโ€™s put these commands into practice: ๐”๐›๐ž๐ซ ๐’๐๐‹ ๐ˆ๐ง๐ญ๐ž๐ซ๐ฏ๐ข๐ž๐ฐ ๐๐ฎ๐ž๐ฌ๐ญ๐ข๐จ๐ง Uses Row_Number() to find the 3rd ride booked: https://lnkd.in/gf4UDx4d ๐†๐จ๐จ๐ ๐ฅ๐ž ๐’๐๐‹ ๐ˆ๐ง๐ญ๐ž๐ซ๐ฏ๐ข๐ž๐ฐ ๐๐ฎ๐ž๐ฌ๐ญ๐ข๐จ๐ง Uses Row_Number() to find odd & even measurements from a sensor: https://lnkd.in/gBUCxxih ๐’๐ฉ๐จ๐ญ๐ข๐Ÿ๐ฒ ๐’๐๐‹ ๐ˆ๐ง๐ญ๐ž๐ซ๐ฏ๐ข๐ž๐ฐ ๐๐ฎ๐ž๐ฌ๐ญ๐ข๐จ๐ง Uses DENSE_RANK() to find the top 5 artists on Spotify: https://lnkd.in/gDJ_paEY ๐–๐š๐ฒ๐Ÿ๐š๐ข๐ซ ๐’๐๐‹ ๐ˆ๐ง๐ญ๐ž๐ซ๐ฏ๐ข๐ž๐ฐ ๐๐ฎ๐ž๐ฌ๐ญ๐ข๐จ๐ง Uses LAG() to find the Year-over-Year Growth: https://lnkd.in/g2WAe2BK

    • No alternative text description for this image
  • Letโ€™s solve this Google SQL Interview Question together: Assume you're given a table with measurement values obtained from a Google sensor over multiple days with measurements taken multiple times within each day. Write a query to calculate the sum of odd-numbered and even-numbered measurements separately for a particular day and display the results in two different columns. ๐ˆ๐ง๐ฉ๐ฎ๐ญ ๐ฆ๐ž๐š๐ฌ๐ฎ๐ซ๐ž๐ฆ๐ž๐ง๐ญ๐ฌ ๐“๐š๐›๐ฅ๐ž: measurement_id | integer measurement_value | decimal measurement_time | datetime Before we start solving this problem, why donโ€™t you give it a try too? You donโ€™t need to login, or install anything, just directly run the query in the browser against the measurements table: https://lnkd.in/gBUCxxih ๐’๐ญ๐ž๐ฉ ๐Ÿ: ๐Ž๐ซ๐๐ž๐ซ๐ข๐ง๐  ๐š๐ง๐ ๐๐š๐ซ๐ญ๐ข๐ญ๐ข๐จ๐ง๐ข๐ง๐  We first order the measurements based on their measurement time and partition them by day using the ROW_NUMBER window function. This helps us establish the order of measurements within each day: SELECT CAST(measurement_time AS DATE) AS measurement_day, measurement_value, ROW_NUMBER() OVER ( PARTITION BY CAST(measurement_time AS DATE) ORDER BY measurement_time) AS measurement_num FROM measurements; It is important to use measurement_time in the ORDER BY clause of the window function to ensure that the measurements are ordered within each day based on the actual measurement's time. This will ensure that the row numbering (measurement_num) is accurate and reflects the chronological order of the measurements within each day. ๐’๐ญ๐ž๐ฉ ๐Ÿ & ๐Ÿ‘: ๐…๐ข๐ฅ๐ญ๐ž๐ซ๐ข๐ง๐  ๐š๐ง๐ ๐’๐ฎ๐ฆ๐ฆ๐ข๐ง๐  To filter for odd and even numbers, we can use the Modulus operator (%)! Use measurement_num % 2 != 0 to check if the result is 1, indicating odd numbers or measurement_num % 2 = 0 with a result of 1 for even numbers. We can apply the modulus concept to the aggregate function SUM() along with the FILTER clause, summing over the corresponding measurement_value, which gives us the final solution ๐“๐ก๐ž ๐…๐ข๐ง๐š๐ฅ ๐’๐จ๐ฅ๐ฎ๐ญ๐ข๐จ๐ง: WITH ranked_measurements AS ( SELECT CAST(measurement_time AS DATE) AS measurement_day, measurement_value, ROW_NUMBER() OVER ( PARTITION BY CAST(measurement_time AS DATE) ORDER BY measurement_time) AS measurement_num FROM measurements ) SELECT measurement_day, SUM(measurement_value) FILTER (WHERE measurement_num % 2 != 0) AS odd_sum, SUM(measurement_value) FILTER (WHERE measurement_num % 2 = 0) AS even_sum FROM ranked_measurements GROUP BY measurement_day; If you want to solve more FAANG SQL interview questions, try these problems: https://lnkd.in/gRtyY3Ht

    • No alternative text description for this image
  • Learning SQL? Here's 3 mistakes beginners learning SQL need to avoid: ๐Ÿ›‘ Mistake 1: Trying to Learn Everything SQL As a beginner, you can skip DDL (CREATE, ALTER, DROP, etc.), DCL (GRANT, REVOKE, etc.) and just focus on SELECT. Basic outline of SQL topics every Data Analyst & Data Scientist needs to know here: https://lnkd.in/e5j7fZpH ๐Ÿ›‘ Mistake 2: Building on Weak Foundations Don't move onto HAVING if you struggle with GROUP BY. Don't learn UNION if you still don't understand JOINs. People are too quick to move onto new commands, because mastering the basics isn't sexy ๐Ÿ™…โ™‚๏ธ ๐Ÿ›‘ Mistake 3: Not Practicing Enough There's a HUGE difference between reading how a SQL command works vs. using it to solve a business problem. For practice, try answering 200+ real-world scenario SQL questions directly in the browser: What mistakes did you make when starting to learn SQL? https://lnkd.in/egwVjb5K

    • No alternative text description for this image
  • DataLemur ๐Ÿ’ (Ace the SQL & Data Interview) reposted this

    View profile for Manya Tyagi, graphic

    Analytics Professional | Driving Operational Efficiency & Decision-Making

    Day 22 out of 50 Starting the journey of sharing #interview questions . Company: Amazon Level: Hard Source: DataLemur ๐Ÿ’ (Ace the SQL & Data Interview) Language/Tool: SQL . Problem Statement: Amazon Web Services (AWS) is powered by fleets of servers. Senior management has requested data-driven solutions to optimize server usage. Write a query that calculates the total time that the fleet of servers was running. The output should be in units of full days. . https://lnkd.in/gKHwwhbT . Here's my approach, what would be yours? . #python #interview #meta #fang #datascience #sql #easy #dailychallenge #50daysofsolving #facebook #MYSQL #HACKERRANK

    • No alternative text description for this image
  • 4 SQL Games that will take your SQL skills to the next level ๐Ÿ‘‡๐Ÿ‘‡๐Ÿ‘‡ ๐Ÿ. ๐’๐๐‹ ๐Œ๐ฎ๐ซ๐๐ž๐ซ ๐Œ๐ฒ๐ฌ๐ญ๐ž๐ซ๐ฒ A murder has happened in SQL city! Can you use your SQL knowledge to find the killer? ๐Ÿ. ๐’๐๐‹ ๐๐จ๐ฅ๐ข๐œ๐ž ๐ƒ๐ž๐ฉ๐š๐ซ๐ญ๐ฆ๐ž๐ง๐ญ Join SQLPD, and solve crimes while learning SQL in the process! ๐Ÿ‘. ๐’๐œ๐ก๐ž๐ฆ๐š๐ฏ๐ž๐ซ๐ฌ๐ž This space-based strategy game implemented entirely within a PostgreSQL database. Compete against other players using raw SQL commands to command your fleet! ๐Ÿ’. ๐’๐๐‹ ๐ˆ๐ฌ๐ฅ๐š๐ง๐ In this adventure game, you're stranded on SQL island after a tragic plane crash, and have to use your SQL skills to find a way to escape the island. Links to each game in this blog post: https://lnkd.in/gUnfa4Kx ๐๐จ๐ง๐ฎ๐ฌ ๐‘๐ž๐ฌ๐จ๐ฎ๐ซ๐œ๐ž: ๐ƒ๐š๐ญ๐š๐‹๐ž๐ฆ๐ฎ๐ซ This interactive SQL interview platform is a simple & fun way to practice solving realistic #SQL problems you'll encounter if you're hunting for a new Data Science/Data Analyst gig!

    • No alternative text description for this image

Similar pages