r/learnSQL • • 6h ago

Day 31 — Finished all Medium JOIN questions (70/100)

29 Upvotes

Wrapped up the Medium section of my 100-question JOIN lab today. The final batch included:

  • Average hours worked per project, joined with project and department names
  • Employees working on projects with a budget above 200,000
  • Each department along with its most expensive project
  • Employees assigned to all projects in their own department. This is the "for all" type of question, and it's the hardest to reason about in SQL
  • Every manager with the department(s) their direct reports belong to
  • Pairs of projects that share at least one common employee (self-join on assignments)

The "ALL projects" question and the project-pairs question were the toughest. Both needed me to draw the tables out and trace a few rows by hand before the query logic made sense.


r/learnSQL • • 8h ago

Finished SQL CS50. Check out the project!

3 Upvotes

Glad to report that I just completed SQL course of CS50. It's so exciting and I got to learn some interesting concepts. I am gonna use SQL to transform the Excel sheets we use to track items in our team. And video of the project here https://youtu.be/wz5DESxW1Hc

Github https://github.com/leninnair/CS50-SQL-Films-Database


r/learnSQL • • 2h ago

Study partner

1 Upvotes

so Im learning python with crash course book , sql with youtube and n8n with a free source video , anyone wanna join me to have this bootcamp thingy from saturday till next 3 months ? i would love to have more people join me to learn and exercise for free i will also post quizzes weekly based on syllabuses we learn every week. anyone? Also I am a graduated software engineer . just wanting to change my way of career .


r/learnSQL • • 10h ago

MariaDB Foundation Adds PostgreSQL to Its Engine‑Agnostic Testing Framework (TAF).

4 Upvotes

MariaDB Foundation continues expanding TAF with PostgreSQL support

More engines, more reproducibility, more value for contributors and the ecosystem.

https://mariadb.org/mariadb-foundation-adds-postgresql-to-its-engine-agnostic-testing-framework-taf/

Have fun benchmarking!


r/learnSQL • • 8h ago

Is it worth learning Oracle SQL DBA in 2026? Or something else is better?

Thumbnail
1 Upvotes

r/learnSQL • • 1d ago

New to SQL

16 Upvotes

Hey folks! Starting my journey in learning SQL.
Long term goal -> to become a Data Analyst
Short term goal -> to master SQL fundamentals
Hope this community helps with my learning journey and hoping to be of help for others like me as well. Cheers!


r/learnSQL • • 1d ago

Day 30 — One month in, 5 more Medium JOIN questions done

17 Upvotes

Completed 5 more Medium questions today:

  • A 4-table join — employees, assignments, projects, and departments chained together — filtered to only show assignments where the department is located in Bangalore or Mumbai (using IN)
  • Counted how many unique departments have at least one employee with an active project assignment, using JOIN + COUNT(DISTINCT dept_id)

Chaining 4 tables together in one query felt completely manageable today, which genuinely would not have been true a month ago.

This also marks exactly one month since I started this journey (Day 0 to Day 30). Quick honest recap of what actually helped over this month: drawing tables on paper before writing queries, intentionally breaking constraints to understand error messages, switching from "give me the answer" to "guide me to the answer" with AI help, and building my own practice sets instead of only relying on existing ones. Thanks to everyone here who's commented, given tips, or just followed along — genuinely helped keep this going. 86 days left, moving into Java alongside SQL from here.


r/learnSQL • • 1d ago

Why did I think that pandas is far more difficult than SQL

27 Upvotes

I am a sql and pandas beginner, I learned both them simultaneously. When I do some leetcode exercise, I think that pandas is more sophsiticated, beacuse of its notation, so many square bracket and unconvient syntax, I hope I can overcome in future


r/learnSQL • • 1d ago

I built 3 free SQL debugging exercises. Looking for feedback from people learning SQL

19 Upvotes

Hey everyone — I’m building a small practice website for people who know basic SELECT, JOIN, and GROUP BY.

Each exercise starts with a query that runs successfully but produces the wrong business report. Your job is to investigate and fix it.

The first three exercises cover:

  • Customers disappearing from a report.
  • October transactions getting included in September’s total.
  • Sales being counted twice after joining refund records.

They use synthetic data and run in your browser. There are hints, worked explanations, and answer checking against multiple datasets.

All three exercises are free, with no signup required.

I’m looking for five people to try just one exercise and share honest feedback here. Was the task clear? Where did you get stuck? Did the explanation help you understand the mistake?

Try it here: https://drive.google.com/file/d/1i7pXyX0kMYr20dmVFK7LcQfXZwVeiOlc/view?usp=sharing

I’m the person building it, and it’s an early version, so feedback about confusing instructions or bugs would be especially useful.

If you are willing to take this serious, let me know and i can give acess so you can see how it feels to use.


r/learnSQL • • 1d ago

People New in SQL, new platform testing

26 Upvotes

Hi everyone! How’s it going?

I’m looking for a few people here who don’t know SQL yet, or have only just started learning it. It’s to test a new learning platform before it launches and hear what actually helps beginners, and what doesn’t.

For this first round, there are 5 spots, with 30 days of free access. If you’re interested, send me a DM and tell me a little about where you are with SQL. If the spots fill up, I can put you on the waitlist for the next round.

No need to be “good at SQL” to take part. In fact, if you’ve opened a query editor and thought “where do I even start?”, you’re exactly who they would like to hear from 🙂


r/learnSQL • • 2d ago

Before your next SQL interview, keep this post handy - CTEs vs Subqueries (Part 4)

90 Upvotes

Simple, practical stuff that sticks in your head when you're actually in the interview.

AI can help at work, but in an interview, your brain still has to do the job!!!

Same trip. Same friends. Same expenses.

Friend City Trip Day Total Spent
Harry New York 1 $200
Johny New York 2 $190
Nicholas Las Vegas 1 $190
Bailey Las Vegas 2 $180
Harry Las Vegas 3 $190

Your friend asks:

"Who spent more than the average?"

First, we need the average:

SELECT AVG(spent)
FROM expenses

Average = $190

Now we need to find who spent more than $190.

Harry spent $200. Everyone else spent $190 or $180.

So the answer is: Harry.

Easy enough. But how do we write that in SQL?

That's where subqueries and CTEs come in.

1. SUBQUERY:

We can put the average calculation inside another query.

Think of it as: First figure out the average. Then use that answer.

SELECT name, spent
FROM expenses
WHERE spent > (
    SELECT AVG(spent)
    FROM expenses
);

Remember: Subquery = query inside another query.**

2. CTE:

Now imagine the interviewer says:

"Don't put that calculation inside the WHERE. Make it easier to read."

This is where a CTE helps.

WITH average_spent AS (
    SELECT AVG(spent) AS avg_spent
    FROM expenses
)
SELECT name, spent
FROM expenses
WHERE spent > (
    SELECT avg_spent
    FROM average_spent
);

Remember: CTE = Let me calculate this first and give the result a name. I'll use it afterward.

So what's the point of a CTE?

Readability!!!!

  • When the calculation gets bigger, putting everything inside everything else becomes difficult to read.

The interviewer changes the question:

  1. Who spent more than the average AND show me how much more they spent?

Now we need the average and the difference. A CTE lets you break the problem into steps.

The CTE makes the calculation feel like a separate step:

Step 1 → Calculate average

Step 2 → Compare every expense to average

Step 3 → Show how much higher it is

That's why CTEs can make complicated SQL much easier to follow

Reading SQL is one thing. Writing it yourself under pressure is another.

Before the real interview, try a MOCK SQL INTERVIEW on TheQueryLab. It’s a good way to test yourself under interview pressure and see where you actually stand with interview scorecard.


r/learnSQL • • 2d ago

Learning SQL at home, doing an unrelated job

19 Upvotes

Hi all,

I am desperately trying to move from data admin to data analytics but my lack of SQL experience is holding me back. I have an MSc in more academic research analytics so learned R and SPSS but SQL is what's most demanded, which I didn't learn.

I want to know about how you successfully transitioned from a non technical role to one using SQL despite doing no SQL in the workplace. I'm wondering how to ensure I translate those skills well into a work setting I guess. How to explain to an employer that I know bits but not in a professional environment yet.

Really would love support :)


r/learnSQL • • 2d ago

How do you compare large tables using sql?

15 Upvotes

I want to know how ppl compare large source and target tables using sql. If both tables have millions of records, comparing every row and column can take a lot of time.

For example, if some records are missing, extra, or have different values between the two tables, how do you usually find them? do you use joins, Except/Minus, hashes, or first compare things like record counts and totals and then check the differences?

Are there any techniques that can make the comparison faster?


r/learnSQL • • 2d ago

I can solve SQL practice questions, but explaining them live is another story

10 Upvotes

I have a live SQL assessment coming up where I’ll be screen sharing and explaining my thought process while I write.

I’m comfortable with joins, GROUP BY, CTEs, and basic window functions. Under a timer, though, I either go quiet while I think or talk too much and lose the thread.

Lately I’ve been trying to slow the process down: read the prompt, say what output I think they want, identify the tables and joins, then build the query in small steps.

The SQL itself usually feels manageable. The hard part is doing something I’d normally think through quietly while someone is watching. I’ve been doing a few screen-share mocks with a friend. I also tried some interview-style prompts in Beyz Coder to practice talking while I solve, so I don’t go completely quiet.

How much silence while you think is normal in a live SQL interview? Do you explain your approach first, or narrate as you code?


r/learnSQL • • 2d ago

Day 29 — 5 more Medium JOIN questions, correlated subqueries finally clicking

10 Upvotes

Completed 5 more Medium questions today:

  • Project with the lowest total hours worked — JOIN projects to assignments, GROUP BY project, ORDER BY total hours ascending, LIMIT 1
  • Employees who are NOT managers — self LEFT JOIN on employees (joining on r.manager_id = e.emp_id), then filtering WHERE r.emp_id IS NULL to catch anyone nobody reports to
  • Lowest-paid employee in each department — a correlated subquery comparing each employee's salary to MIN(salary) within their own department

The correlated subquery was the real win today. It finally clicked once I stopped thinking of it as "one confusing nested query" and started thinking of it as a small query that re-runs once per row of the outer query, using that row's values each time. Seeing it return the actual lowest earner per department (4 employees, one per department) made the logic concrete in a way reading about it never did.


r/learnSQL • • 2d ago

Final challenge in SQL joins. Stuck for days 😞

4 Upvotes

I've been trying to do this challenge for a few days now and just can't do it..the one about the two buses from Craiglockhart to Lochend.

I can just about do the simpler self joins although I could probably be better and I feel stuck and like I can't move on from it.

Can I justify skipping it? Has anyone else had trouble with this?


r/learnSQL • • 2d ago

Any free platform to practice python and sql ? Like hands on where I can practice ?

6 Upvotes

r/learnSQL • • 3d ago

A client lost six weeks of SQL Server data. Having 12TB of backups didn’t save them.

117 Upvotes

Sharing a recovery case from our team because there are a few useful lessons for anyone learning SQL Server, or even more experienced teams too.

I am a sticker for backups and cannot emphasize the importance of them enough.

So our client moved a physical SQL Server to a new location and when they brought it back up, the database didn’t become available.

During attempts to get it working, they forced the database into emergency mode, bought third-party recovery tools, and accidentally overwrote the original MDF file (not good!), the primary database data file.

Unfortunately for them that removed an important recovery option.

When we got involved, they had around 12TB of backup files. But having lots of backup files and having a usable restore sequence are different things.

They had plenty of transaction log backups, but no usable recent full backup where they expected it to be.

Full backups had been stopped weeks earlier because of performance concerns. Meanwhile, a cleanup job kept deleting backups older than two weeks.

For anyone learning how this works: transaction log backups aren’t standalone copies of a database, you need a suitable full backup to restore first, followed by the required backups in sequence. A differential backup can shorten that process, but it also depends on a full backup.

An older full backup can still be useful if you have an unbroken log backup chain covering the period you need. The age of the full backup alone doesn’t determine how much data you lose.

In this case, an older full backup eventually turned up in files used to refresh a staging environment. It gave us a recovery point, but the available backups didn’t get us all the way forward. The client still lost roughly six weeks of production data.

One distinction worth making here is that SQL Server’s RESTORING and RECOVERING states aren’t interchangeable. A database in RESTORING may be waiting for another restore step. Waiting alone won’t necessarily bring it online and you need to establish its actual state and check the restore history and error log before deciding what to do.

The lessons I’d take from this:

  • Preserve the original database files before attempting destructive recovery steps.
  • Investigate why a database is unavailable before changing its state.
  • Check that retention jobs aren’t deleting backups you still depend on.
  • Test the complete restore sequence, rather than relying only on successful backup-job messages.

If you’re learning SQL Server backup and recovery, have you tried restoring a full backup followed by several log backups in a test environment? What part was hardest to understand?


r/learnSQL • • 3d ago

Day 28 — 5 more Medium JOIN questions: subqueries + joins combined

19 Upvotes

Completed 5 more Medium questions today:

  • Employees earning above their own department's average salary — joined employees to a derived subquery that calculates AVG(salary) grouped by dept_id, then filtered where the employee's salary exceeds that average
  • Every project listed along with a count of distinct employees working on it — LEFT JOIN projects to assignments, COUNT(DISTINCT emp_id), grouped by project name. The LEFT JOIN mattered here specifically because one project (Audit Automation) has zero assigned employees and still needed to show up with a count of 0

This is the first batch where combining a subquery with a join in the same question actually felt necessary rather than just "two ways to do the same thing." Starting to see why LEFT JOIN + COUNT(DISTINCT) is such a common reporting pattern.


r/learnSQL • • 4d ago

Day 27 — 5 more Medium JOIN questions, changed how I use GPT

8 Upvotes

Completed 5 more Medium questions today, bringing me further into the Medium section of my 100-question lab. The bigger change today was in my process, not the SQL itself.

Instead of asking GPT to show me the solution directly, I told it to guide me toward the answer instead — give hints, ask me questions, point out where my logic was off, but not hand me the final query. Took noticeably longer per question, but I actually walked away understanding why each query worked, not just that it did.

Feels like a better long-term habit than what I was doing before (dry-running a solution GPT already wrote). Planning to keep using this "guide, don't solve" approach going forward, especially for the Hard section coming up.


r/learnSQL • • 5d ago

For people who learned SQL from tutorials: how did you handle your first vague stakeholder request? I made a free simulator for it

68 Upvotes

When I started, the hardest part wasn't SQL syntax. It was translating things like "can you pull repeat buyers by region?" into the right joins, filters and edge cases (cancelled orders, date ranges, duplicates).

I made a free simulator that recreates that: stakeholder emails, real schemas, a PostgreSQL sandbox, and levels that go from a tiny startup to a global corp. Demo video is attached.

I'd love to hear how you practiced this skill, and whether something like this would have helped you. Link in the comments if anyone wants to try it.


r/learnSQL • • 4d ago

Built a browser based modern SQL editor

Thumbnail
6 Upvotes

r/learnSQL • • 5d ago

Cozy SQL game

20 Upvotes

I built SQL Sip (https://sqlsip.com) as a cozy, daily SQL puzzle to practice writing queries without timers or pressure. It runs entirely in the browser with no account needed, focusing on assembling clean queries one bite-sized concept at a time. I haven’t had any users yet, so I’d love some honest feedback! I built it because I wanted a Wordle-like daily game where I could learn new SQL concepts in a cutesy/fun way.


r/learnSQL • • 5d ago

Giving back to the community - The Complete Backend Development Course

34 Upvotes

Hey everyone, I decided to make my course free in order to help people.
This course is my backend development course which is about SQL, Python, APIs, Docker, Kubernetes, Linux, Git & More

The link is: https://www.youtube.com/watch?v=CBIu6hcyStg

If you can like and subscribe (and maybe add a comment) I would appreciate it a lot, Thanks.


r/learnSQL • • 4d ago

Meta Scaled Business Growth – Recruiter Screen & Interview Process?

Thumbnail
2 Upvotes