r/learnSQL • • 1h ago

Title: SQLPractices.com – A Great Resource for Learning SQL

4 Upvotes

I've been using SQLPractices.com to strengthen my SQL skills, and it's been a great learning resource.

I particularly appreciate its structured approach, practical business scenarios, and progressive exercises across Beginner, Intermediate, and Advanced levels.

The hands-on exercises covering aggregations, GROUP BY, and JOINs make it easier to translate theoretical knowledge into practical skills. I thought I'd share it for anyone looking for a good SQL learning resource. :)


r/learnSQL • • 8h ago

Manager will pay for one SQL course and I don't know how to pick

14 Upvotes

I'm in finance and I'm SO tired of waiting days on someone else to pull numbers!! My manager finally said yes to paying for one SQL course 🙌 I'm leaning toward the longest one I found, it goes through joins and window functions...but I have no idea how to judge if any of them are good. What course did you take that got you writing your own queries at work?


r/learnSQL • • 2h ago

A day-7 retention exercise: why the answer is 1/3, not 2/4

1 Upvotes

A retention query can return a plausible percentage while quietly answering a different question. Here is a small SQLite example you can inspect end to end.

Question: Of the users whose first observed activity was January 1, 2026, what percentage were active exactly seven days later?

The fictional log has four users:

  • User 1 first appears January 1 and returns January 8. Both dates have duplicate activity rows.
  • User 2 first appears January 1 and returns January 7, not January 8.
  • User 3 first appears December 31 and is also active January 1 and January 8.
  • User 4 first appears January 1 and returns January 9.

Before reading the query, decide whether the answer should be 1/3 or 2/4.

Complete runnable SQLite setup and solution:

CREATE TABLE user_activity (
    user_id INTEGER,
    activity_date TEXT
);
INSERT INTO user_activity VALUES
    (1, '2026-01-01'), (1, '2026-01-01'),
    (1, '2026-01-08'), (1, '2026-01-08'),
    (2, '2026-01-01'), (2, '2026-01-07'),
    (3, '2025-12-31'), (3, '2026-01-01'),
    (3, '2026-01-08'),
    (4, '2026-01-01'), (4, '2026-01-09');

-- SQLite. Dates are validated ISO YYYY-MM-DD text.
WITH params AS (
    SELECT '2026-01-01' AS cohort_date
),
first_activity AS (
    SELECT user_id, MIN(activity_date) AS first_activity_date
    FROM user_activity
    WHERE user_id IS NOT NULL AND activity_date IS NOT NULL
    GROUP BY user_id
),
cohort AS (
    SELECT f.user_id
    FROM first_activity AS f
    CROSS JOIN params AS p
    WHERE f.first_activity_date = p.cohort_date
),
retained_users AS (
    SELECT DISTINCT a.user_id
    FROM user_activity AS a
    CROSS JOIN params AS p
    WHERE a.activity_date = date(p.cohort_date, '+7 days')
      AND a.user_id IS NOT NULL
)
SELECT
    COUNT(c.user_id) AS cohort_size,
    COUNT(r.user_id) AS retained_users,
    100.0 * COUNT(r.user_id) / NULLIF(COUNT(c.user_id), 0)
        AS retention_rate_pct
FROM cohort AS c
LEFT JOIN retained_users AS r ON r.user_id = c.user_id;

The result is 3 cohort members, 1 retained user, 33.3333% retention.

Three details determine that answer:

  1. MIN(activity_date) establishes each user's first observed activity using the full supplied history. Filtering to January 1 before computing the minimum would wrongly admit User 3.
  2. SELECT DISTINCT deduplicates returning users, so repeated activity does not multiply their contribution.
  3. The LEFT JOIN keeps users who did not return in the denominator. NULLIF makes the percentage NULL if the cohort is empty.

Counting anyone active on January 1 gives 2/4 = 50%, but that answers a different question. Exact day-7 retention also differs from returning at any point during the following week.

To run this without installing anything, open https://sqlite.org/fiddle/ . If it starts at a terminal prompt, choose Toggle view, paste the full SQL into the input box, and choose Run. Use a new example database; Reset DB clears the fictional table before rerunning the setup.

The data must contain the relevant history and validated ISO dates. First observed activity is not necessarily a signup date. With incomplete history, the query cannot establish a true signup cohort.

The same exercise, explanation and copyable SQL file on GitHub.

Disclosure: I'm the creator, Israel Diego Guerra. AI assisted preparation, and I executed this exact example in SQLite and its official browser Fiddle. The linked lesson ends with an optional link to my $79 interview pack; all data, the query and the answer are free above and on GitHub, without signup.


r/learnSQL • • 1d ago

How to learn postgresql

11 Upvotes

Did learning express. so as next step in thinking of learning postgresql instead of mongodb. so how. how did you learn. my stack is pern and is it good??


r/learnSQL • • 1d ago

Which books worked best for you?

14 Upvotes

I know this is potentially an FAQ and the common answer will be to point me to a website or a course but I’m in a bit of a tricky situation in that I need to learn SQL for my job but my employer will only fund books rather than courses so I was wondering which books worked best for you guys? Thanks.


r/learnSQL • • 1d ago

Quick SQL puzzle. Why does this LEFT JOIN lose the customer with no orders?

15 Upvotes

There are two customers. Customer 1 has one paid order. Customer 2 has no orders.

I want both customers in the result, with paid order details where available.

SELECT c.id, o.status

FROM customers AS c

LEFT JOIN orders AS o

ON c.id = o.customer_id

WHERE o.status = 'paid';

This only returns customer 1. My first instinct would be to look at the join, but the row actually disappears because of the WHERE clause.

The fix here is to move o.status = 'paid' into the ON condition and remove the WHERE clause. That way the join looks for a paid order, and customer 2 still shows up with NULL for status.


r/learnSQL • • 1d ago

3 YOE Database Dev (SQL/PLSQL) → aiming for product/GCC. Already shortlisted some books – feedback on my list + personal experiences?

Thumbnail reddit.com
2 Upvotes

r/learnSQL • • 2d ago

What to do next??

20 Upvotes

I have completed SQLbolt and I want to keep learning SQL for data analysis. I want to move on to the intermediate and advanced level in it.

Alsooo , I need to practice it too and I need project ideas which I can build and actually add in my portfolio.

Any help is appreciated.


r/learnSQL • • 2d ago

How to fix a error 1100?

5 Upvotes

SQL Error [1100]: Query execution failed: INVALID_FUNCTION_ARGUMENT: Invalid format: "01/07/2026" is malformed at "/07/2026"

Query execution failed: INVALID_FUNCTION_ARGUMENT: Invalid format: "01/07/2026" is malformed at "/07/2026"

INVALID_FUNCTION_ARGUMENT: Invalid format: "01/07/2026" is malformed at "/07/2026"

AI Aint helping


r/learnSQL • • 3d ago

What SQL concept did you understand in tutorials but mess up in practice?

18 Upvotes

For me, joins are the best example of this. The diagram makes perfect sense. Then you join two tables, get twice as many rows as you expected, and suddenly you’re questioning everything.

What was that topic for you? And what finally made it click?


r/learnSQL • • 4d ago

I added 300 FAANG-style SQL interview questions (basic to advanced) to my free practice site.

18 Upvotes

A while back I shared SQL Office Simulator, where you play a company's data analyst and answer stakeholder requests. A common ask was interview prep, so I pivoted into an Interview Mode.

What's new:

• 300 interview-style questions, from basic to advanced

• Modeled on what big tech and top startups actually ask: joins, window functions, CTEs, retention/cohorts, deduping, running totals, top-N per group, and so on

• Same PostgreSQL 16 sandbox, with hints and a schema viewer

• Free, with a quick signup to save progress

The video shows one question from start to submission.

Link: sql office

I'd love blunt feedback:

  1. Do the questions match what you've seen in real interviews?
  2. Is the basic-to-advanced progression right?
  3. Which topics are missing?

r/learnSQL • • 4d ago

what finally got you from copying old T-SQL patterns to understanding SQL server properly?

11 Upvotes

I write T-SQL every single day at work. A lot of it I couldn't explain to you.

I have a folder of old scripts I copy from. When I need to dedupe something I grab the ROW_NUMBER() OVER (PARTITION BY ...) one and swap the column names. I could NOT tell you what changes if I mess with the ORDER BY inside the OVER.

A proc that always ran in a couple seconds started taking minutes, with zero code changes. Our DBA said "parameter sniffing," ran a recompile, and it was fast again.

I want to know how SQL Server builds a plan for my query and why it picks a different one some days.


r/learnSQL • • 4d ago

SQL problem solving

6 Upvotes

I uploaded some YouTube videos explaining/solving SQL problems from HackerRank and DataLemur here
This would've been very useful for me when I first started learning SQL, so if you're starting your journey or need to practice some more, feel free to give it a look and let me know if you have any feedback. Thanks.


r/learnSQL • • 4d ago

Completed SQL foundation from SQL Bolt, Now practicing on Hackrrank What to do next for learning more concept.

6 Upvotes

Confused on what to learn next, have a thought of learning T-sql.


r/learnSQL • • 4d ago

Learning SQL from Today 2 DEC 2026

30 Upvotes

So currently, I'm walking in a non-tech company where my role is aviation security in India where I don't see any growth salary wise as well as in any kind of knowledge and skills. So I want to switch in a tech fild like data analysts , business analyst or product analyst. So i'm learning SQL because it's requiring mostly all tech field

So help me with my journey where I can learn a square. Basically, I'm looking for some sight where I get data. Because on YouTube, I don't get data, they show me table and I have to manually. You know, I don't know the details and it's very time consuming and it's not efficient for me.

It's so pleasant.Tell me where I can get our date.Real data on which I can run queries and as well as any website or youtube channel which is very good for learning

I'll appreciate for replying to this post.Do help me, guys.I need your support if anyone also learning.We can talk in d m like how we can help each other and grow together


r/learnSQL • • 4d ago

Opening new spots for free zoom SQL lesson

41 Upvotes

Hey! I've been giving my first 10ish FREE SQL zoom sessions for people who want to learn or improve on SQL, and have more availabilities this week. Learning it helped get promoted so happy to help other people with theory and real exercises. let me know if interested


r/learnSQL • • 4d ago

Creé SQLab ES: una plataforma interactiva en español para aprender SQL resolviendo 12 casos de investigación (React + SQLite WASM + PHP)

Thumbnail reddit.com
2 Upvotes

r/learnSQL • • 5d ago

I made a free site that animates every SQL query step by step (feedback welcome)

78 Upvotes

When I was learning, the hard part was that you can't see what a query does. So I built SQL Bun. you write a query and watch each clause act on the rows, in the order the database actually runs it.

I wanted to make learning SQL interactive and fun.

There are 47 short lessons and 70+ interview-style problems. No account needed.

I'd love to know which parts are confusing.


r/learnSQL • • 5d ago

Advent of SQL 2026: 24 Christmas puzzles on 3 Different Databases (Duck, Postgres, SQLite)

17 Upvotes

Happy Holidays, r/learnSQL!

Somebody tampered with Santa's Nice List, and you're the North Pole's first-ever data elf.

This year, I decided to build a free, interactive Advent of SQL & NoSQL: 24 puzzles, one a day from December 1 to 24, designed to help you practice SQL while solving a Christmas mystery.

Every day, you get a bit more of the story and a question to answer with a query: which toys to build first, which children flipped from nice to naughty overnight, whose badge was used on the night shift, who walked through which door and when. By Christmas Eve, you'll have worked out who did it and fixed the list.

You can choose between three SQL databases, following the same story and working with the same underlying data:

  • SQLite
  • DuckDB
  • PostgreSQL

There's also a MongoDB version for anyone interested in exploring NoSQL!

More details:

  • Everything runs entirely in your browser. There's nothing to install, no backend database server, and nothing to connect to.
  • Beginner-friendly, with increasing difficulty. Early puzzles cover filtering, sorting, GROUP BY and joins. Later ones introduce window functions, recursive CTEs, relational division and running totals.
  • Your answer gets checked instantly, against both visible and hidden datasets with different values. Reading the answer off the screen and hard-coding it won't pass.
  • Practice different SQL dialects. You can solve the same puzzles across different databases and explore their differences.
  • Hints and common pitfalls for each day, if you get stuck, plus a short "did you know" tip about your chosen database.

Whether you're just starting to learn SQL or looking to sharpen your existing skills, hopefully there's something here for you!

A new puzzle unlocks every day until Christmas Eve!

Pick your database here: https://visualeaf.com/advent-of-sql-and-nosql/

Completely free. No account, no installation, no database server needed.

I hope you all enjoy it, and happy holidays!


r/learnSQL • • 5d ago

Tired of setting up Oracle/Postgres/SQL Server just to practice SQL, so I made a browser sandbox (no ad, no signup)

11 Upvotes

Hi, Im studying sql grammars and tuning skils to get professional sql certification: SQLP (Korean SQL certification)

I had trouble with setting up database servers and data initalized, it take too many time after that I have no time for practice .... lol

So I made a Sandbox for studying SQL in web without server (yeah server is mine)

Can practice various sql grammars and tuning cases, it provides platforms: oracle, postgresql, ms-sql server (plus wiki for database)

I wish everyone who study sql focus on practicing (not setting up server and data)

It's totally free and no sign-up needed.

It covers:

- Basic queries (SELECT, WHERE, ORDER BY)

- Joins

- Subqueries

- Set operations (UNION, INTERSECT, EXCEPT)

- Window functions

- PIVOT

There's also a quiz mode: you get a real-world style requirement

(e.g. "Find the top 3 customers by total order amount in each region"),

write the SQL yourself, and run it against the sample data to check if you got it right.

Link: https://database.devio.sh/sql

it is early,so I really appreciate any feedback! Thank so much.


r/learnSQL • • 6d ago

What kind of SQL questions do companies usually ask in technical interviews?

55 Upvotes

I'm preparing for SQL interviews and curious about what companies actually focus on during technical rounds.

Do they mostly ask basic queries, JOINs, subqueries, window functions, or real-world problem-solving questions? Would love to hear what you experienced in your interviews.


r/learnSQL • • 6d ago

Use Case of Views and Materialized Views???

6 Upvotes

Hi there,

As a beginner of learning sql , I really don't know where the data analysts folks actually use of Views and materialised Views to analyse the real world data. Are people really use this in the real world problems day to day .

Help me to understand where is the real use case of these in the real world problems


r/learnSQL • • 7d ago

How do you practice SQL beyond basic exercises?

71 Upvotes

I'm currently learning SQL and trying to move beyond simple queries and textbook exercises.

Most exercises tell you exactly what to calculate, but real business problems seem much less structured.

Where do you find realistic SQL projects that require independent thinking?

I'm also researching what could make practical SQL learning resources more useful.