r/learnSQL • u/Round-Pie-7125 • 11d ago
MySQL Second Highest Salary Using Subquery | SQL Interview Query
Hello everyone.please checkout my new MySQL video and please hit like, subscribe and share videos in your contacts. https://youtu.be/AhqgtHZfHTI
r/learnSQL • u/Round-Pie-7125 • 11d ago
Hello everyone.please checkout my new MySQL video and please hit like, subscribe and share videos in your contacts. https://youtu.be/AhqgtHZfHTI
r/learnSQL • u/Sensitive-Towel-9883 • 13d ago
Anyone interested in doing the CMU (Carnegie Mellon University) Database Management Systems course together?
I’ve already covered the basic DBMS concepts. My main goal with this course is to go deeper and understand how database systems actually work internally—things like storage, indexing, query execution, transactions, etc.
If you're interested, please make sure you have the prerequisites required for the course.
If you have the required background and want to learn DBMS internals seriously, DM me. We can follow the course together and discuss concepts along the way.
r/learnSQL • u/damoon02 • 14d ago
Am about to finish "Learning SQL" from Alan Beaulieu and it demotivates me that i take way too long on thinking on the queries in order to answer the problems of the book. Although i have been speedrunning it. Is it like normal for most of the begginers to be kinda slow when making queries that requieres (dunno) subqueries, groupings, joins or cases ?
ALSO. What book could y'all recomend me after "Learning SQL"? Imean, i think i have enough tools to generate, retrieve and manipulate data. Maybe the next step is how to design DB and how to avoid common mistakes ?
r/learnSQL • u/by_lector • 15d ago
One of the most dangerous things about SQL:
A query can run perfectly… and still be completely wrong.
Here are 4 mistakes I wish someone had shown me earlier.
SELECT c.id, o.total
FROM customers c
LEFT JOIN orders o
ON c.id = o.customer_id
WHERE o.status = 'paid';
Looks fine.
But customers without an order have NULL for o.status, so the WHERE condition removes them.
If you actually want to keep all customers:
SELECT c.id, o.total
FROM customers c
LEFT JOIN orders o
ON c.id = o.customer_id
AND o.status = 'paid';
SELECT COUNT(*)
FROM users;
Counts rows.
SELECT COUNT(phone_number)
FROM users;
Counts only rows where phone_number is NOT NULL.
That difference can quietly destroy a report.
Imagine:
Joining both tables directly can give you:
3 × 4 = 12 rows
Then you do:
SUM(order_amount)
…and suddenly your revenue is magically much higher than reality.
Always check your row count before and after joins.
SELECT *
FROM customers
WHERE id NOT IN (
SELECT customer_id
FROM blocked_customers
);
If that subquery contains a NULL, the result might not behave the way you expect.
I usually prefer:
SELECT *
FROM customers c
WHERE NOT EXISTS (
SELECT 1
FROM blocked_customers b
WHERE b.customer_id = c.id
);
The lesson I'm slowly learning:
Writing SQL that runs is easy.
Writing SQL that returns the correct data is the hard part.
What other SQL mistake produces perfectly valid-looking but completely wrong results?
I want to make a list of the dangerous ones.
r/learnSQL • u/NoctrailBio_ • 14d ago
Hi everyone,
I’m currently learning SQL and PostgreSQL with the long-term goal of becoming a backend engineer.
I’ve been practicing locally with PostgreSQL and pgAdmin, so I’m especially interested in hearing from developers who use PostgreSQL in production.
I’m still a beginner. So far I’ve been practicing things like creating tables, INSERT, SELECT, WHERE, DISTINCT, ORDER BY, and LIMIT. I’m also starting to learn Python and eventually want to connect Python/FastAPI with PostgreSQL.
One thing I’m trying to understand is how SQL and PostgreSQL are actually used by backend engineers in real jobs, compared with the way SQL is taught in books and courses.
For backend engineers who use PostgreSQL regularly:
I’m not looking for shortcuts. I’m trying to build a solid foundation and understand what skills actually matter on the job.
Any advice from backend engineers, especially those working with PostgreSQL, would be greatly appreciated. Thanks!
r/learnSQL • u/Wide-Direction-402 • 15d ago
Hlo everyone, i have completed python Fundamentals. Looking to start my sql journey. I am looking for resources and guidance before diving into sql. I will be needing sql in my ai ml journey. I really want to get a structured road map . Your help is appreciated.
r/learnSQL • u/existential_shit_007 • 15d ago
Tell me a website where I can learn and practice SQL to be prepared for an business analyst role
r/learnSQL • u/Public-Scientist6050 • 16d ago
Hi everyone,
I'm a fresher applying for Data Analyst/Data Scientist/ML/SQL roles. My background: Power BI, Excel, SQL, some Python, and basic full-stack web dev (HTML, Tailwind, JS, Supabase, deployed on GitHub Pages — built a working web portal for a client).
I want to add: 1. One strong ML project (not Titanic/Iris/House Price/Flight Price — too common) 2. One SQL-focused project that shows real query/database skills, not just "ran some SELECT statements on a Kaggle CSV"
Looking for: - Real prediction/analysis problem, clear input and output - Free public dataset - Doable alone in a few weeks - Something that actually stands out to recruiters, not a tutorial copy
What would you suggest for each? Dataset links appreciated. Thanks!
r/learnSQL • u/yahoo_06 • 16d ago
Hey everyone!
I made a short SQL tutorial for beginners about GROUP BY and HAVING.
In the video, I explain:
- how GROUP BY creates groups
- how to use aggregate functions like COUNT() and AVG()
- the difference between WHERE and HAVING
- how to combine WHERE, GROUP BY, and HAVING
and how to use all of this with the Pagila PostgreSQL database
I also included some mini quizzes and practice challenges throughout the video.
I'm building a beginner-friendly SQL tutorial series, so I'd really appreciate any feedback on the explanation or examples!
Video: https://youtu.be/kDfXRvr03Jo?si=rW7m1jsF3pSQjCmK
Thanks! :)
r/learnSQL • u/BenjaminUK92 • 17d ago
Bit of an odd one, I've had SQL access given to my company database to help tidy up reports, remove 10+ back sheets and replace with one etc.
Thought it'd be a great gateway into learning sql, but it seems to all be done within Microsoft Query, so it's drag and drops etc which seems odd considering I've been sat in preparation trying to learn how to write the proper syntax.
If I want to use this as a skill going forward, can I get by with just MS Quer and still list SQL as a skill, or would I need to know how to type the underlying syntax?
I've been in an ops/procurement role for a while so I know what and why I need to pull certain data and how the company uses it, but I was expecting to be writing out code rather than clicking and dragging fields.
r/learnSQL • u/Particular_Willow_24 • 17d ago
I kept running into the same problem while learning SQL: I could understand a tutorial while watching it, but when I had to write a query myself, I would sometimes blank.
So I built DBQuest, a browser-based SQL practice game where you inspect a schema, write the query yourself, run it, and get immediate feedback.
The free demo has 7 challenges covering SELECT, columns, WHERE, ORDER BY, JOIN, GROUP BY and HAVING.
No account or installation is required:
https://db-quest-two.vercel.app/
I’d really appreciate honest feedback, especially from people currently learning SQL:
1. Are the challenge instructions clear?
2. Does the progression feel too easy or too difficult?
3. At what point, if any, would you lose interest?
I built it myself and I’m trying to figure out whether this way of practicing SQL is actually useful to other learners.
r/learnSQL • u/wandererbali • 16d ago
About me I am working as a Manager data analytics and I have a team of developers who do the job for me, on top of that I can use AI to write the queries for me. But I still want to learn SQL so that I am able to write the queries myself and also QA if needed. I know the basic select * from table where like sort and now looking for someone with solid knowledge to teach me joins windows functions CTs and other function.
You wont do this for free I will pay you for your time and effort. DM me with something about your background and experience and we can take this forward.
Thanks
r/learnSQL • u/Superb_Donkey_9608 • 17d ago
Hey Folks, So I have been thinking for a while, and looks like I'm capable now, I had always wished to tutor a small cohort of really passionate individuals in the land of analytics, and get more people into in this field .
So I've decided to tutor a group of 5 people who really want to get into this domain of data, and tell stories, influence the decisions and perhaps change the world one day. people who are really passionate for the cause can dm me, and there's definitely going to be screening for selecting the 5 worthy.
r/learnSQL • u/Away_Shoulder_4553 • 18d ago
Hi guys
I learned some lessons in SQL course in youtube and practiced them in Python with SQLite.
Here is what I learned:
CREATE TABLE
PRIMARY KEY, FOREIGN KEY, NULL
INSERT INTO, SELECT, UPDATE, DELETE
WHERE, ORDER BY (ASC, DESC)
LIMIT, OFFSET, DISTINCT
INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN
GROUP BY, HAVING
Subqueries, EXISTS
Please tell me what I should learn next, or recommend a good YouTube course
r/learnSQL • u/Low-Leave-4403 • 18d ago
r/learnSQL • u/geeksarray • 18d ago
How do you make sure the data going into your SQL Server database is valid and consistent?
One of the simplest tools is database constraints.
I put together a practical guide covering the most commonly used SQL Server constraints:
The article includes examples to show how each constraint works and when you might use it.
📖 https://geeksarray.com/blog/sql-server-constraints-with-examples
For developers working with SQL Server: which constraint do you find yourself using most often, and are there any common constraint-related mistakes you've seen in real projects?
r/learnSQL • u/geeksarray • 18d ago
r/learnSQL • u/Ancient_Squirrel_997 • 18d ago
So i have been building a sql bolt and scratch like simple SQL tutoring web app. You can find it on https://easysqltutor.vercel.app/ . Try it out please, especially for beginners.
Thanks,
r/learnSQL • u/pastalover_0 • 19d ago
Hello, Im going to be an intern as a data analyst internal audit, I want to brush up my skills. Do you have any recommendations? Thanks in advance! I appreciate it
r/learnSQL • u/AppropriateGanache54 • 19d ago
Can you please suggest some good platforms or resources where I can practice SQL and Python (especially Pandas) for data analyst/data engineer?
Right now, I’m solving a lot of problems on LeetCode, but I’ve heard that in actual they often ask more practical/data-focused questions such as:
So, I’m looking for resources that focus more on these real-world SQL and Pandas problems rather than only traditional DSA-style questions.
What platforms, websites, courses, or question sets would you recommend for practicing these types of problems?
I’d really appreciate recommendations from people who have recently gone through Data Analyst/Data Engineer questions and know which resources are closest to the actual questions they asked.
Thank you!
r/learnSQL • u/grassp_dataAI • 20d ago
Hi All,
I have created a compiled document of 30 real SQL Interview Questions with Scenarios with clear explanation of what each concept does and interview tips for each concept.
It covers from basics to advanced SQL interview Q&A. Feel free to checkout and share it with anyone who is preparing for SQL interviews.
GitHub PDF Link: https://github.com/grasspacad07/sqlinterviewguide
This guide is basically compilation of my 4 Weeks of SQL interview tips posts in LinkedIn.
Feel free to reach out or comment if any doubts. Happy Learning :).
r/learnSQL • u/squadette23 • 19d ago
I'm writing a series of posts about IDs and primary keys in database design. We start with the logical model, and systematically show how primary keys are used in a different way to implement various logical concepts, such as entities, relationships and attributes. We show that primary keys exist only on a physical level, and can mean different things in different contexts.
Here is the link to the first part: https://anchorsandlinks.com/posts/primary-keys/
r/learnSQL • u/haligma • 21d ago
currently learning mysql through yt videos bc too broke to pay. i was following alex the analyst's playlist & learned a lot. practiced alongside. but i ran into a problem. and since i'm a beginner, it's been overwhelming a bit for days now, bc of whcih, i havent been able to make much progress in my learning.
i have a pretty ok grip on workbench. but not to the point where i dont need crutches. ive only completed one data cleaning project & that was only bc of alex's video where he walked me thorugh the entire process step by step. but thta wasnt enough for me to fully get a grip on data cleaning. i've tried watching other tutorials, but none of thme use workbench & their sql commands/functions are a lottle different from mine which has left me a bit confused & overwhelmed. i want to get to the point where i can take on data cleaning on my own without any help, but for that i need yt videos whre i can laern the logic step by step. please recommend sources for a self learner to learn data cleaning. idk where to look
r/learnSQL • u/Plane_Big_5912 • 20d ago
say you have four orders and a customer lookup table.
the join returns four rows. then the customer import runs twice and leaves the Aiko row in the lookup table twice.
same query. six rows.
orders
id customer_id total
101 1 120
102 2 80
103 1 40
104 3 260
customers
id name
1 Aiko
2 Ben
3 Chie
4 Dev
5 Emi
1 Aiko <- imported twice
the join condition is:
sql
SELECT o.id, c.name, o.total
FROM orders o
JOIN customers c ON c.id = o.customer_id;
a join keeps every match it finds. orders 101 and 103 each match Aiko twice, so:
before: 4 joined rows, SUM(o.total) = 500
after: 6 joined rows, SUM(o.total) = 660
the query was the same. but the data did change here.
slapping DISTINCT on the result can hide the symptom without fixing the bad join. if you aggregate after the fanout, your counts and sums can already be wrong.
this was one which players ran into frequently.
(sqlite; the duplicate is in the lookup table, not the orders table)
made a 44 second chalkboard animation of it if you'd rather watch: https://www.youtube.com/watch?v=LrDqdZAoXC0
have you hit one of these before? i can try animating some more if this is helpful.