🌐
Scribd
scribd.com › document › 597667511 › LeetCode-SQL-Questions-With-Solutions
LeetCode SQL Questions With Solutions | PDF
LeetCode SQL Questions With Solutions - Free download as PDF File (.pdf) or read online for free.
Rating: 5 ​ - ​ 1 votes
Discussions

What I have learned by solving (almost) all the SQL problems in Leetcode
🌐 r/dataengineering
51
89
April 12, 2023
SQL Practice for interview
https://advancedsqlpuzzles.com You can try the above. There is a GitHub with a pdf of puzzles. More on reddit.com
🌐 r/SQL
20
37
March 18, 2024
mysql - Here is No.183 sql questions from Leetcode. There is one answer that do really fast but I am confused - Stack Overflow
Questions: There are two tables: Customers and Orders. Write a solution to find all customers who never order anything. Here is the answer: SELECT name as customers FROM customers WHERE (SELECT COU... More on stackoverflow.com
🌐 stackoverflow.com
For those wanting to practice SQL on LeetCode but don’t have a LC subscription, I created a Python program that re-creates all the problems in db-fiddle.com

Not to be a spoil sport, but it could probably be construed as copyright infringement.

Just thought I'd mention it in case you're concerned about that sort of thing.

More on reddit.com
🌐 r/SQL
23
145
December 24, 2018
🌐
GitHub
github.com › mrinal1704 › SQL-Leetcode-Challenge
GitHub - mrinal1704/SQL-Leetcode-Challenge: Contains all the 117 Leetcode questions with their solutions ranging from Easy to Hard in MySQL.
Contains all the 117 Leetcode questions with their solutions ranging from Easy to Hard in MySQL. - mrinal1704/SQL-Leetcode-Challenge
Starred by 815 users
Forked by 520 users
Languages   TSQL
🌐
Studocu
studocu.com › marathwada mitra mandal's polytechnic › computer science › leetcode sql questions and solutions for exam preparation
Leetcode SQL Questions and Solutions for Exam Preparation - Studocu
August 16, 2022 - 🔺 Leetcode🔺SQL Questions WITH Solutions ✔️ · Anonymous Student · Academic year · 2017/2018 · Category · Practice materials · Report Document · APPROVED · End of document · Was this document helpful? 843 · Report Document · 7. Survey of Nvidia: Grading Investment, Production & Turnover · MPL 2019 Oral Question Bank on 80386 Microprocessor with Answers ·
🌐
GitHub
github.com › ieshreya › sql-50-leetcode
GitHub - ieshreya/sql-50-leetcode: Solutions for SQL 50 Study Plan on LeetCode · GitHub
Solutions for SQL 50 Study Plan on LeetCode · 1757 - Recyclable and Low Fat Products · SELECT product_id FROM Products WHERE low_fats = 'Y' AND recyclable = 'Y' 584 - Find Customer Referee · SELECT name FROM Customer WHERE referee_id != 2 OR referee_id IS null ·
Author   ieshreya
🌐
LeetCode
leetcode.com › discuss › general-discussion › 2064076 › list-of-all-free-45-sql-leetcode-questions-easy-medium-hard
✅ List of All Free 45 SQL Leetcode questions
May 22, 2022 - Clone it !! list : https://leetcode.com/list/e97a9e5m Upcoming post 🔥: All SQL Leetcode questions with their most intuitive solutions. ---- T
Find elsewhere
🌐
Reddit
reddit.com › r/sql › sql practice for interview
r/SQL on Reddit: SQL Practice for interview
March 18, 2024 -

Hello guys, I recently completed the leetcode 50 Sql problems and earned a badge but to be honest for the most questions I watched the solutions and completed that thing. So I am not satisfied with myself so I want to solve more like that can you guys give some website or challenges like leetcode to practice for interviews and it will be useful for everyone who seeing this post

And yeah the leetcode 50 Sql problems link is here please check it out: https://leetcode.com/studyplan/top-sql-50/

Suggest me something like this.

Top answer
1 of 5
10
https://advancedsqlpuzzles.com You can try the above. There is a GitHub with a pdf of puzzles.
2 of 5
10
Use all the other interview sites Data Lemur. Pretty great, the SQL study guide Nick wrote is fantastic. The site has solid UI not cluttered or obtrusive. The best way to learn is to get to a solution and then compare your solution to the "official" solution of the problem AND look at the solution discussion section. https://datalemur.com/blog/sql-interview-guide Code Wars. Similar to the above but more user submitted questions and definitely helpful to practice targeted concepts. You can see the community voted solutions and how yours compares with great community tags. https://www.codewars.com/kata/search/sql?q=&tags=SQL&beta=false&order_by=sort_date%20desc StrataScratch. Often argued that THIS site is the LeetCode for the data community. Like LeetCode but data focused, has take homes, has great UI. Solid site, definitely worth a subscription but there's free problems too no money necessary. https://platform.stratascratch.com/coding?code_type=1&page_size=100 Interview Query. Like stratascratch, Jay is a Youtuber and provides a lot of material and help. I don't know which one is better or worse but you can check out both and their materials and pick. SQLPad. Not the IDE, yet another interview site. Analyst Builder, from Alex the Analyst. https://www.analystbuilder.com/ https://www.alextheanalyst.com/interview-prep . Also has free and paid options of questions and courses. Similar interface I think to neetcode's site. Alex is definitely more Data Analyst focus but there's a lot of cross-pollination. Data Lemur, Interview Query and SQLPad are from people who are active in the data community, I think all Ex-FAANG Data Scientists. They target getting you ready for the FAANG interviews. Stratascratch is really LeetCode for Data, more generalized than the others. I think HackerRank and LC are again more for SWEs than DS/DA/DE roles not that there's any distinction, it's just that you'll have more data focused questions in the data focused sites. If that's what you're looking for however. And these are actual interview questions, not so much SQL questions asked by a general SQL quiz. Nick has a great writeup on the distinction of that. There's nothing wrong with that for general knowledge, infact you'll be expected to know that material like Join Types and the theory etc. but you'll need to know MORE than that. Interview Questions are phrased in different ways, they won't just say "join this table to this table" or "do you know what a LEFT vs FULL is?" They expect that, they'll give you a toy business scenario and expect you to use the syntax you know to solve it.
🌐
Medium
kawsar34.medium.com › leetcode-sql-50-part-1-8b76ed9ee193
Leetcode SQL 50 Part 1. SQL, or Structured Query Language, is… | by Shahidullah Kawsar | Medium
February 10, 2024 - LeetCode has launched a study plan “SQL 50”, with 50 questions to practice your SQL skills.
🌐
LeetCode-Solutions
libaoj.in › LeetCode-Solutions › SQL
Database Questions | LeetCode-Solutions
Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL query to find all customers who never order anything. Table: Customers. +----+-------+ | Id | Name | +----+-------+ | 1 | Joe | | 2 | Henry | | 3 | Sam | | 4 | Max | +----+-------+ Table: Orders.
🌐
LeetCode
leetcode.com › discuss › general-discussion › 1208129 › list-of-free-leetcode-sql-questions
List of Free Leetcode SQL Questions
List of Free Leetcode SQL Questions · Abhishek Singh Baghel · 260298 · May 14, 2021 · May 14, 2021 · Database · https://leetcode.com/problems/big-countries ·
🌐
LeetCode
leetcode.com › studyplan › top-sql-50
SQL 50 - Study Plan - LeetCode
50 essential SQL questions · Best for 1 month of prep time · Award · SQL 50 · Complete the study plan to win the badge!
🌐
LeetCode
leetcode.com › problem-list › m8baczxh
Free SQL questions - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
🌐
Medium
medium.com › acing-the-software-engineer-interview › sql-a3d82018badc
SQL Leetcode. Found an online cheatsheet | by LiveRunGrow | Acing the Software Engineer Interview | Medium
June 16, 2023 - SELECT question_id survey_log FROM SurveyLog GROUP BY question_id ORDER BY COUNT(answer_id)/COUNT(question_id) DESC, question_id LIMIT 1 ... +---------------+---------+ | Column Name | Type | +---------------+---------+ | id | int | | country ...
🌐
Scribd
scribd.com › document › 744897816 › SQL-Leetcode-Questions
SQL Leetcode Questions | PDF
JavaScript is disabled in your browser · Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
Top answer
1 of 1
2
SELECT name AS customers
FROM customers
WHERE (
        SELECT COUNT(*)
        FROM orders
        WHERE customerId = customers.id -- the "correlation" is here
        ) < 1

The given answer (which isn't necessarily the best possible solution) is using a "correlated subquery". This "correlation" takes place through the where clause of the subquery and it enables the subquery to "align" the subquery result (i.e. the count(*) value) to each row of the customers table, then that value is compared to <1.

Characteristics of a "correlated subquery"

  • Nested queries: The SQL statement has a query within a query. The "inner query" (everything inside the parentheses) is nested within the "outer query".
  • Reference to the "outer query": The "inner query" is referencing customers.id which comes from the "outer query". This is the key characteristic of a correlated subquery.
  • Row-by-row execution: Correlated subqueries run once for each row processed by the outer query. In this case, for each customer, the database is counting the number of orders that customer has
  • Performance: Correlated subqueries can be slower than other types of queries because they require multiple executions of the inner query

There are at least 2 other approaches for such a problem:

  • using NOT EXISTS (also known as a "left semi-join"), or
  • using a LEFT JOIN and WHERE clause (sometimes known as "left excluding join")
    -- using NOT EXISTS
    SELECT name AS customers
    FROM customers
    WHERE NOT EXISTS (
            SELECT 1
            FROM orders
            WHERE customerId = customers.id -- "semi-join" formed by this
            ) 
    ;
    
    -- using LEFT JOIN
    SELECT name AS customers
    FROM customers
    LEFT JOIN ORDERS ON orders.customerId = customers.id
    WHERE orders.customerId IS NULL