Master Your Next Data Interview: Excel in SQL, Python, & R

Elevate your career with advanced data analytics and engineering expertise.

Our tailored courses and interactive coding challenges are designed to sharpen your foundational skills in data and AI. Dive into hands-on exercises and gain expert insights in Data Engineering, Data Science, and AI essentials. Propel your professional growth and interview mastery to new heights.

1. SQL March Leaderboard #1 Coder: Steven

Steven πŸ₯‡Gold


2. SQL March Leaderboard #2 Coder: Newmen

Newmen πŸ₯ˆ Silver


3. SQL March Leaderboard #3 Coder: Varun

Varun πŸ₯‰ Bronze


4. SQL March Leaderboard #4 Coder: Peter

Peter πŸ—‘ Iron


5. SQL March Leaderboard #5 Coder: Howard

Howard ⚑️ Krypton


6. SQL March Leaderboard #6 Coder: George

George


7. SQL March Leaderboard #7 Coder: Alien

Alien


8. SQL March Leaderboard #8 Coder: ZET

ZET


9. SQL March Leaderboard #9 Coder: Mandeep

Mandeep


10. SQL March Leaderboard #10 Coder: mei

mei

Master data skills, double your earnings.

A curated list of 230 SQL & Python coding questions and solutions.

Available engines: PostgreSQL, MySQL, Python and R.

97. Social influencer

easy facebook

  • Write a query to return the user's id with the most friends.
  • Hint:We can assume there is one and only one person with the most friends, there is no tie.
  • A request can be accepted multiple times.

Table: accepted_request

Log when a friend request is accepted


  col_name      | col_type
----------------+------------------------
 sender_id      | bigint
 recipient_id   | bigint
 acceptance_dt  |  date

Solution postgres

SELECT user_id_1 AS user_id
FROM (
	SELECT sender_id AS user_id_1, recipient_id user_id_2
	FROM accepted_request
	UNION 
	SELECT recipient_id AS user_id_1, sender_id user_id_2
	FROM accepted_request
) X
GROUP BY 1
ORDER BY COUNT(DISTINCT user_id_2) DESC
LIMIT 1;
    

Explanation

This query selects a user (aliasing it as "user_id") who has the most distinct accepted requests with other users.

To do this, it starts by creating a subquery that combines the sender and recipient IDs from the "accepted_request" table. It does this twice, once for each direction of the request (sender to recipient and recipient to sender). This is done using the UNION operator.

The resulting table is then grouped by the "user_id_1" column (which contains the user ID from the first column of the subquery). It counts the distinct "user_id_2" values (which contains the user ID from the second column of the subquery) for each "user_id_1". The results are then sorted in descending order based on the count of distinct "user_id_2" values.

Finally, the query selects only the first row (using LIMIT 1), which will be the user with the most distinct accepted requests with other users.

Expected results

Join over 50,000 happy customers, including many from the world's best companies and universities.

Land a dream position at Amazon!

Hi Leon, I hope you're doing well. I wanted to reach out and say thanks for your interview prepβ€”it really helped me land a position at Amazon. It's been a fulfilling experience!

Data Engineer Offer from Amazon!

I got a job offer at Amazon as a Data Engineer! I worked with Leon and he was super helpful to me at every stage of the process of getting a new role! He helped me strategize a study plan for technical interviews, shared knowledge of what different data roles are like and which one I would like, and evaluate and negotiate what is important to me in the offer!

The best thing that I learned working with Leon is how to spend my time effectively in the interview process. Interviewing is not one of my strengths, but Leon empowered me to get to my goals!

Leon is really smart and has years of experience in Data, and knows the hiring process inside and out. It is so worth it to be able to learn from his experience! I have nothing but gratitude!

Senior Data Engineer Offer from Spotify!

Got an offer from Spotify for a Senior Data Engineer role! I worked with Leon to negotiate my salary.

Leon helped me approach negotiations with an assertive mindset and answered questions that helped lessen my anxiety.

While it was terrifying to imagine potentially losing a good offer, I thought that talking through strategy and potential scenarios with Leon helped me to construct a game plan that I felt comfortable with.

I think this service is great and I'm definitely going to use it again for my next job search!.

50% Salary Increase! !

Thank you so much @Leon!

Your advice and coaching are extremely helpful for preparations for the interviews. The timeline and pacing you helped plan worked out very well.

It kept me on the right track. The exercise on coding and data analytics you recommended greatly sharpened my skills to solve the problems during the technical rounds.

The practice to communicate project work to peers is another highlight to help me earn higher score. Again thank you so much for all your advice!

Dream job offer from ο£Ώ Apple!

Hi @Leon and @Mike ,

Just wanted to share, I accepted an offer from Apple as a Data Engineer and wanted to offer a huge thank you to both of you guys.

Even though I only shared a time with you both I benefited a lot from your platform and your mock interviews.

Some of the questions you gave during our Data Modeling with you Mike were presented verbatim.

Recommending him!

Shout out to Leon Wei from sqlpad.io, recommending him if you are searching for great advises and mentorship for your #datasciences career.

The mock interview helped me do it in the right way

πŸ’¬ SQLPad helped me gain mastery of all the core SQL concepts in a structured manner with a thoughtfully designed business schema. The associated articles and videos are also very well produced and helped me get a better understanding of translating business questions to actual SQL code. Highly recommended for anyone looking to deepen their SQL skills and those applying for data analytics roles.

Shoutout to Leon Wei from instamentor.com.

Please do reach out to him if you're looking for career advice, general consulting, or resume feedback. I found his services extremely valuable.

And while you're at it, please do check out SQLPad if you're looking to refresh your SQL concepts.

sqlpad.io seems more intuitive and lightweight where some of the other sites try to do too much and they're a bit cumbersome to use.

I like the Leaderboard. Probably my biggest reason for signing up was the fact that you gave so much information away for free.

I signed up for your emails, was going through the mini courses, using the Playground and I got more benefit out of all of that in two weeks than I did at the other websites. Glad I found sqlpad.io.

Received offers from Walmart and Jaguar Land Rover

Thank you so much for your help and support this year. I am pleased to say I received two offers Software Engineer 3 at Walmart and a Senior Machine learning engineer position at JLR based out of the UK.

Simply put, SQLPad is not the cheapest SQL interview prep site, but its high quality SQL interview questions makes it worth every penny. You can't practice anywhere else of such well thought and carefully designed business context oriented list of SQL coding questions.

I nailed my SQL interviews and received multiple Data Scientists offers that potentially double my currently salary, which makes the few hundreds dollars purchase of SQLPad lifetime bundle a steal.

I can always come back and use SQLPad when I want to prepare my next SQL interview.

Dream data scientist job offer!

I've tried several sites to practice SQL and sqlpad.io is my favorite because the questions are well-designed to focus on the most important concepts. Some of the other sites are all over the place.

With sqlpad.io, I can focus on questions by skill level or topic, and the number of questions available is a reasonable amount to study for interview prep.

In addition, I got mentoring sessions with Leon and I was impressed at how helpful it was. Leon was calm and knowledgeable, which helped my nerves over my up-coming interview.

He really takes mentoring seriously and it makes a big difference. After practicing my SQL, I got my data science dream job!

Yes, I really like it too. Simple, straightforward and to the point. It is really helping me a big time. Yesterday, I have solved a few questions on sqlpad and the similar problem I had to solve at work today. The methodology really helped me to build an efficient solution. I can recommend this platform to my friends and colleagues without any doubt.

I want to give a big shout out to @theleonwei, founder of SQLPad. Absolutely had the pleasure of learning SQL on SQLPad. There are 80 plus SQL challenges ranging from easy to hard. I can now say that I have become more confident.

Worked through all the problems at sqlpad - Great teaching / refresher tool and highly recommended!

I have been relearning SQL and sqlpad has been a great resource. There is a good ratio of a new concept to practice questions! Highly recommended.

πŸ’¬ "I signed up on SQLPad and was pleasantly surprised when Leon helped me out personally on the website.

In two mock interviews with him, he was meticulously prepared and very professional.

Throughout the interview he provided fantastic feedback and frameworks on how to be better prepared for both technical and behavioural aspects of an interview. He is also a very positive and friendly person and I enjoyed all my interactions with him.

πŸ’¬ SQLPad is the best website I have used for practicing SQL. The databases and practice problems resemble real-world data and daily tasks in a data scientist / data analyst role. I landed a new job as a data scientist at a tech company after completing all the practice problems. I would definitely recommend SQLPad to all who would like to improve their SQL skills and prepare for technical interviews.

πŸ’¬ This course helped me get into a final round of a data scientist interview at Facebook. Didn't get an offer eventually because I didn't do well during the product sense round. However I got great feedback for my SQL interview session. Highly recommend this course to any fresh college graduates.

πŸ’¬ I want to thank you for creating this website and it is a great resource for anyone to practice. I really appreciate the effort. I feel so confident with SQL after practicing here.

πŸ’¬ I am currently in question 30, I really like some of the questions you posted here. Also thank you for your excellent customer service !!!! Thanks πŸ‘‹πŸ‘‹πŸ‘‹

⭐️⭐️⭐️⭐️⭐️

πŸ’¬ Enjoying it so far, love the mix with practical exercises and the focus to land a job, that's really important because normal courses do not prepare you for interviews. Also, Leon is really kind and helpful.

πŸ’¬ This site is a great resource for SQL interview practice questions. The interface is excellent! And even as someone who currently uses SQL for their day job, I have definitely improved my skills by working through these problems.

πŸ’¬ Thanks for sqlpad. Really loving the experience. As someone transitioning into a data analyst position this is a great resource. Looking forward to your mentorship program.

⭐️⭐️⭐️⭐️⭐️

πŸ’¬ Great course on SQL. Very comprehensive. All the SQL material I've pales compared to this.

SQLPad Value Calculator

Enter your current salary and see how much more you could be making with a high paying job in tech.

What is your current annual salary?

How many years of work experience do you have?

Choose a 3 months SQLPad Plan

SQLPad starts at only

$79/mo

you could earn an extra

$0

your return of investment in SQLPad

0%

πŸ”₯ Get My Dream Job Offer

This salary estimate is based on the internet compensation data for data scientists at top U.S. tech firms, including FAANG companies. However, individual circumstances can vary significantly. Factors like your performance in the interview, the job's geographic location, and how urgently the company needs to fill the position could all influence your final offer. Therefore, consider this information a useful reference point, rather than a guaranteed outcome.

Data engineers and machine learning engineers often earn more than data scientists. If you're on an engineering career path, your return on investment might be even better than you think!

Commonly asked questions

Picture this: you're scrolling through LinkedIn when suddenly, a message pops up, "Do you have time for a chat this week?"

It's a recruiter from none other than Google, your dream company. Your heart skips a beat.

You manage to impress in the initial call with the recruter, and then you're onto the technical round 3 days later.

This is it, your moment to shine.

But the task is to write a SQL query to identify top search terms by country.

Despite being a SQL wizard at work, without your trusted code editor, the familiar auto-complete, and the usual business context, you find yourself floundering.

Minutes tick by, and you can sense the interviewer's interest waning as he started looking at his phone.

You cobble together a semi-optimized code and present it, only to be met with a quick glance and a glance at the watch.

"We have 5 minutes left, do you have any questions for me?" he ask, signaling the end.

The next day, an email arrives from the recruiter.

It's polite, regretful—they've decided not to move forward. Those words sting, leaving you wondering, "What went wrong?"

Does this scenario sound painfully familiar?

It's a story we've heard too many times, and it's exactly why SQLPad was created.

SQLPad is more than just a learning platform; it's your end-to-end career launchpad.

Beyond our expertly designed courses and interactive coding challenges in SQL, Python, R, and machine learning, SQLPad brings an innovative suite of AI tools to elevate your job application process.

From crafting the perfect resume to penning compelling cover letters, our AI-driven assistance ensures your first impression is as impressive as your skills.

But we don't stop there. Our AI-powered mock interview feature simulates real-life interviews with hiring managers, allowing you to practice your responses, refine your delivery, and gain valuable feedback in real-time.

This unique tool is designed to build your confidence, ensuring you can articulate your value and tackle any question with poise and assurance.

Ready to transform your job application from a point of stress to a point of strength?

Dive into SQLPad's offerings now and land your dream job!

Yes, we now offers one time annual passes. Pay once and forget about it. No surprises, no hidden charges. 

Save up to 70%, and there is NO RECURRING CHARGES

Check it out: SQLPad Annual Pass here.

Certainly, many customers have had their subscriptions reimbursed by their employers, enabling them to study SQL and Python without incurring personal costs.

Most companies allocate a specific annual budget (thousands of dollars) for employee training and learning, both for tax advantages and other benefits.

Furthermore, numerous companies automatically approve expenses under $100 without the need for managerial consent.

Here is a sample invoice you can use to get reimbursed.

sample sqlpad invoice for reimbursement

Need some help convincing your manager? Here is a draft email for your reference:

Dear Elon,

I would like to request your support in reimbursing my SQL and Python training at SQLPad.io.

By learning SQL and Python, I can improve my productivity and work more efficiently in managing and analyzing large datasets.

I have reviewed the course materials and believe that the interactive tutorials and real-world projects would provide a comprehensive learning experience. This investment will benefit not only me but also our team and the organization as a whole. Thank you for considering my request.

Best regards,

Steve

You are given 10 FREE SQL/Python coding questions to try out, after that, your account will be locked.

Upgrade to a paid plan will unlock it immediately and also give you access to all questions and solutions, as well as the SQL, Python, Machine Learning Courses.

On average, it takes about 3-4 months to finish all the coding questions.

Since we have already provided you a FREE tier to practice a limited set of questions, we cannot refund you once your subscription starts.

Cancellation and Refund Policy

1. Monthly/Quarterly subscriptions
Once your subscription starts, you CAN NOT get a refund for any payments you've already made.
If you don't want to subscribe anymore, cancel your subscription.

You will have access to the subscription until the end of the period you have paid for.

2.  One time purchase

Unfortunately, we can not refund one-time purchases, including but not limited to EBook, Ultimate Bundle, and Job Search ultimate bundle.

Absolutely, congratulations, and we totally understand you need to take a break and celebrate.

To cancel your subscription, simply:

1. Sign in to your account, go to your account dashboard, then click Manage Plan.

2. A customer portal page will pop up (Hosted on Stripe). Follow the step-by-step instructions to cancel your subscription.

What happens after?

You will still have access until the end of your subscription period, similar to your other subscription like ο£Ώ Apple Music or Netflix.

If you want to delete your account permanently, shoot us a message with your username and email, and we will delete your account within 24 business hours.

Leon Wei, SQLPad founder Hi, my name is Leon Wei. Most recently, I was a senior manager of machine learning at ο£Ώ Apple. I am currently building an AI data analytics tool: skills.ai while running sqlpad.io. You can read more about me at my linkedin profile.

I’ve been using SQL for over 10 years, and it is still my go-to programming language to prepare data.

Before that, I lead a team of data scientists and engineers at Chegg, helping students or young professionals to improve their performance at school or work.

I also worked as a research scientist at Amazon, focusing on building a large-scale real-time pricing optimization engine for their online retail business. 

We created the cracking the SQL interview for the data scientist course with a beginner's mindset, and we assume our audience has 0 experience with SQL.

That's why the first 10 questions may seem to be very easy for experienced users, but you will find more and more challenging and tricky hard level questions as you move along to later questions.

The goal of sqlpad is to help people in data analytics/science quickly learn or refresh their SQL, Python/Pandas skills.
It could be for a job interview or be more productive at work.

We offer 20% off for students, educational institutions and startupsEmail us (hello at sqlpad dot io) from your .edu or work email to request a discount code.

We do not offer any other discounts.

Unfortunately NO.

We have designed and created the entire SQL course and curated all 200 SQL coding questions single-handedly, which took us more than 3000 hours of hard work, therefore you are not allowed to use any of those questions outside of this website, without our written permission.

If you represent a company and are interested to acquire a license to use our coding questions and solutions, please feel free to contact us.

From sqlpad's founder Leon wei.

After launching the Cracking the SQL Interview for Data Scientists course, I realized the need for my students to easily follow the course and practice SQL coding problems.

Since I can't find a solution online, I built SQLPad.

All the SQL exercises can be practiced in a browser, and my students don't have to waste hours configuring the database on their own computers.

As of March 21, 2023.

Those are the major version of our online playground.

PostgreSQL: 13.9

MySQL: 8.0

Python: 3.10

Pandas: 1.5

 

SQLPad is the Leetcode alternative that makes learning and mastering SQL for data analytics professionals instead of software engineers. It creates a complete SQL mastery path for all data scientists.


πŸ§‘‍πŸ’» Our approach to tackling a SQL interview is to first teach you SQL fundamentals with the cracking the SQL Interview for data scientists course before asking you to jump into the coding war.

πŸ“Ή More than 20 video lectures to learn SQL fundamentals and tips and tricks help you understand what a SQL interview is about.

πŸ‹οΈ‍♀️ After you grasp the basics, you then jump into SQL coding questions that challenge you and make sure you mastered those SQL fundamental concepts.

😱 Leetcode jumps directly into some super long, hard-to-understand SQL coding questions that may frustrate you, especially if you just started.

πŸ“ˆ Instead, SQLPad has a more gradual, more user-friendly learning experience for all SQL skill levels.

🍿 The first 80 SQL coding questions are based on the same Movie rental database, which resembles a real-world commerce business.

πŸ€— From easy-level questions to challenging ones, you gradually build up a good understanding of the database schema by practicing those questions.

πŸ‘©‍πŸ’» And by the time you are to solve some of the most advanced SQL interview questions (#58-80), such as WINDOW functions and LAG/Lead, you are already familiar with those tables. You can jump right into the coding environment after learning the concepts.

The Cracking SQL Interview course is a comprehensive course but is really focused on improving your SQL interview skills, with tips and techniques that I've learnt from interviewing thousands of data professional candidates. It saves time by concentrating on things that really matter.

We have seen satisfied customers ranging from fresh college STEM students searching their first industry jobs, and young professionals who want to switch their career track to work on data science.

SQLPad and the SQL interview course significantly improved their hands-on data processing capabilities, with laser-focused learning materials, to help land their dream job offers.

(Update 01/26, 2022, we now also support MySQL and Python, more info.)

Great question, SQLPad's online playground, and the coding challenge's online judge is currently based on the latest Postgres.

Its query syntax is similar to other databases such as MySQL or Microsoft SQL Server, one of the major differences is on Postgres's DateTime related functions.

More details can be found here: https://www.postgresql.org/docs/current/functions-datetime.html

For example, there is no datediff function in Postgres, but you can subtract one DateTime column from another directly using the minus '-' operator, which is actually quite convenient and easier to type once you get the hang of it.

If you would like to see other database engines implemented on SQLPad, please let us know.

 

 

There is definitely a lot to prepare for your first job hunt, especially given the current COVID-19 situation, hiring managers to receive a lot more applications from qualified candidates, and it pushes the hiring bar significantly higher than before.

If you are interested to know more about how to prepare a data scientist interview, I wrote a blog to explain different types of data scientists tracks.

And if you are interested in finding a job search mentor to help you get started with a concrete plan. Feel free to email us if you have any questions.

Yes, we now support dark mode!

To switch between light and dark mode, simply click the toggle button located at the top right of the navbar.

Yes, you totally can.

SQL interview questions and  SQL Playground work in all modern web browsers, including Chrome, Safari, Firefox in ο£Ώ Mac, Windows, Linux  and other operating systems.

Good question, I created the solutions in a specific style/format (e.g., using IN instead of JOIN), so my students who take the Cracking the SQL interview for Data Scientists Course can follow along.

I have been gradually adding more solutions (optimized) and will indicate if that solution is for more advanced users.

If you have a better solution than mine, please feel free to let me know!

 

SQL is a must-know programming language for any analytics track data scientists, it is the lingua franca for processing and managing data in the industry. I’ve been using SQL for many years, and it is still my go-to language to prepare and manage data.

However, it is not a strong-typed language, and there are many popular database systems with different syntaxes and built-in functions, it could be very confusing for first-timers.

As a hiring manager or part of the hiring committee, I often ask a lot of SQL questions during a data scientist job interview, and to make sure the candidate will be hands-on at work.

However, in my 15 years career, I have met so many fresh college graduates or young professionals starting their job searches without solid coding skills in SQL, and in the end, they didn’t get a job offer.

The SQL interview can bear other names and may be called  Technical Analysis or Data Interview during a FAANG company interview, you might be asked to perform a series of SQL operations to extract data and insights, and answer follow-up questions about their products.

(*) FAANG: Facebook, amazon, apple, Netflix and google

Have more questions? Please feel free to contact us, we read and respond to every email you send us, just give us some time. πŸ˜ƒ

Begin Your SQL, R & Python Odyssey

Elevate Your Data Skills and Potential Earnings

Master 230 SQL, R & Python Coding Challenges: Elevate Your Data Skills to Professional Levels with Targeted Practice and Our Premium Course Offerings

πŸ”₯ Get My Dream Job Offer