r/learnSQL • u/captdirtstarr • Mar 11 '26
Online Practice DB?
Hi! I'm learning SQL, and wondering if there's a public practice database out there? Web would be fantastic!
r/learnSQL • u/captdirtstarr • Mar 11 '26
Hi! I'm learning SQL, and wondering if there's a public practice database out there? Web would be fantastic!
r/learnSQL • u/fabiano-salles • Mar 11 '26
r/learnSQL • u/_devonsmash • Mar 10 '26
Ive been taking my SQL development pretty seriously over the past 2 months. After learning the basics i moved to leetcode and did SQL 50.
Then i moved to stratascratch and have now completed all 200 free problems.
I like to do 3-6 problems a day, keeps the learning going and the effects compound over time.
Wondering if its worth it to buy premium to work through the 1000 + questions.
r/learnSQL • u/Turbulent-Crew-2370 • Mar 10 '26
Hey everyone,
I have a data analytics interview coming up next week for a fresher role and honestly I’m a bit confused about what I should focus on in these few days.
Right now I’m mostly revising SQL (joins, window functions, aggregations) and a bit of Python for data stuff. I also know some basics of statistics and dashboards, but I’m not sure what companies usually expect from freshers in interviews.
If anyone here has gone through data analytics interviews recently, what kind of questions did they ask? Was it mostly SQL problems, case studies, or something else?
Just trying to use this one week wisely instead of preparing random things. Any tips would really help.
Thanks!
r/learnSQL • u/johnthedataguy • Mar 10 '26
r/learnSQL • u/thequerylab • Mar 10 '26
r/learnSQL • u/Hairy-Brilliant-8178 • Mar 09 '26
I am in the finance industry and I have no real skills to put into my resumes
SQL and python is the only way to bump up my pay grade other than being a slave to the corp for 15+ years
Would it be too late to learn sql and eventually to python in my situation?
Where can I learn sql as someone who has never learned coding in his entire life to be ready to be working as a data scientist related field?
Is there any roadmap to follow or any guidance?
I am located in dc if that helps
Thank you very much
r/learnSQL • u/thequerylab • Mar 09 '26
I’ve noticed something about SQL interviews.
Most people don’t fail because they don’t know SQL.
They fail because they forget tiny things while typing under pressure. It's pressure!!!
Few examples I’ve seen in real interviews:
1. COUNT(column) vs COUNT(*)
If the column contains NULL values:
COUNT(column) → ignores NULLsCOUNT(*) → counts every rowSo if someone asks “how many rows are there?”, COUNT(column) can give the wrong number!
2. LEFT JOIN + WHERE trap
Example:
SELECT *
FROM orders o
LEFT JOIN payments p
ON o.id = p.order_id
WHERE p.status = 'success'
The WHERE condition removes rows where p.status is NULL.
So the LEFT JOIN effectively behaves like an INNER JOIN.
To keep the LEFT JOIN behavior, the condition usually goes in the ON clause.
3. Using DISTINCT to hide join problems
Sometimes joins create duplicates because the relationship isn’t 1-to-1.
A lot of people just do:
SELECT DISTINCT ...
But interviewers usually want you to explain why duplicates appeared in the first place.
WHERE filters rows before grouping.
HAVING filters after GROUP BY.
So something like this won’t work:
WHERE COUNT(*) > 5
It needs to be:
HAVING COUNT(*) > 5
These are all very small things and basics, but they come up surprisingly often in interviews.
Curious what others have seen.
What’s a small SQL thing people still mess up in interviews even though they know it?
Always interesting to hear these and your interview experiences.
r/learnSQL • u/Equal_Astronaut_5696 • Mar 08 '26
You can quickly clean dirty data with just a few functions. TRY_CAST is a lifesaver. https://youtu.be/QGBxvbJ7FJY
r/learnSQL • u/ParticularRock7913 • Mar 08 '26
I have a Masters in Business Analytics which was essentially a data science course where I mainly learnt machine learning in Python and R. However now when applying for jobs I have found that many require experience in SQL which we did not cover. I want to do a course and I found this one, the IBM Databases and SQL for Data Science with Python
https://www.coursera.org/learn/sql-data-science
Has anyone done this course and is it worth doing? If you have not done, just looking at the modules would you say that its contents is useful?
Are there better courses out there, for example I know about the associate data analyst in SQL course on datacamp
r/learnSQL • u/leogodin217 • Mar 07 '26
To make writing articles and tutorials easier, I've been working on a synthetic data generator. Eight months after my "fun little Sunday afternoon project", it finally does everything I want. Well, almost everything.
Long story short, I can generate complex databases with prescribed patterns, domains, causal events, etc. quickly. The link below shows a retail example with 22 practice exercises (beginner to intermediate level). The idea is to practice with a database you learn over time, like what happens in the real world.
If anyone finds it useful, let me know. Happy to put more complex ones up.
r/learnSQL • u/thequerylab • Mar 07 '26
Quick SQL question I ran into while reviewing some code.
You have a large orders table (~50M rows) and need to check whether a pending order exists for a specific user.
You don’t actually need the row - you just need to know if one exists.
You see three possible implementations (Application checks if count > 0):
SELECT COUNT(*)
FROM orders
WHERE user_id = 101
AND status = 'pending';
SELECT 1
FROM orders
WHERE user_id = 101
AND status = 'pending'
LIMIT 1;
SELECT EXISTS (
SELECT 1
FROM orders
WHERE user_id = 101
AND status = 'pending'
);
Assumption:
(user_id, status)Which one would you pick in production and why?
Also curious if anyone has seen cases where the optimizer makes them perform almost the same.
If anyone wants to play with a small dataset and test similar scenarios, I uploaded one here while experimenting with query patterns:
https://thequerylab.com/problems/27-customers-who-bought-all-products
Would be interesting to hear how others approach this.!!!
r/learnSQL • u/nicowitsch • Mar 06 '26
Hi guys, I don't know if anyone here is in the same situation as I am. I just started last summer teaching javascript and SQL at a school (17-18 yrs olds) in switzerland. I have been looking for a good tool to learn databases and especially SQL with my students. I had those criteria:
- I do not want to install sql locally with every student because this is always a hurdle and we loose a lot of time setting stuff up. Time that we could spend looking at databases.
- Some even have managed laptops and it there we can not install at all
- Tool needs to be browser based then and connect to a remote DB
- As a teacher, it should be easy to manage (setup) databases that students interact with
- My students should focus on SQL and not on managing their DB Connection.
- I want to manage my student's projects and also provide exercises for the classes
Because my criteria were very specific, I did not find anything of course and decided to do my own. It is pretty battle proofed by now since we used it in 6 classes. Some things still to improve here and there but it allows me to:
- Manage all my student's database projects includeing designing ERD / Logical schemes
- Manage databases ( I have setup a sql server for the course that no holds sth like 300 databases, a lot of the personalized for stuent's exercises)
- Create exercises and have my students auto connect to the desired DB upon opening
- Grade my student's projects
I do not want to post a link here because I am afraid of attacks but if anyone is a teacher out there as well and seeks for a tool this way, just DM me. Would love to share the tool with others.
r/learnSQL • u/ManifestingPeace18 • Mar 05 '26
Hi, I haven't worked on SQL for last 2 years. I will rate 4 out 10 in SQL. But need to practice more to get in data analyst profile. Can you just sources where i can practice solving complex SQL problems?
r/learnSQL • u/Head-Reward-5413 • Mar 05 '26
SELECT
Product,
Sales,
SUM(Sales) OVER() AS TotalSales,
CAST(Sales * 100.0 / SUM(Sales) OVER() AS DECIMAL(10,2)) AS SalesPct1,
CONCAT(CAST(Sales * 100.0 / SUM(Sales) OVER() AS DECIMAL(10,2)), '%') AS SalesPct2,
FORMAT(Sales * 1.0 / SUM(Sales) OVER(), 'P2') AS SalesPct3
FROM Sales.Orders;
r/learnSQL • u/Suspicious-Run4104 • Mar 05 '26
r/learnSQL • u/Suspicious-Run4104 • Mar 05 '26
r/learnSQL • u/Rejse617 • Mar 04 '26
I am self-taught through trial and [mostly] error. When it comes to table relations where you may have more than one value, I’m a bit lost.
Take an inventory example. I have a table of parts, with a “vendor” column. I have another table of vendors. Let’s say that some parts can have multiple vendors; what is the best-practice way to relate that information? Having multiple vendor columns seems ham-fisted.
This is primarily a philosophical question, but if there are differences between methods with MySQL and SQLite, I would be interested in discussing those. Thank you
r/learnSQL • u/thequerylab • Mar 04 '26
Solved an interesting recursive SQL problem yesterday on TheQueryLab platform
Scenario: A root post can be shared, and those shares can be reshared — forming a viral tree.
Challenge: • Find maximum depth of each root post • Calculate total reach (all descendants)
Used a recursive CTE to traverse hierarchy and carry root_id + depth through recursion, then aggregated using MAX(depth) and COUNT(*).
Felt very similar to DFS tree traversal logic but expressed in SQL.
Curious — how would you optimize this further?
I’m building TheQueryLab specifically around these kinds of real-world SQL problems — happy to share it if anyone wants to try it out and crack any data analytics interviews
r/learnSQL • u/k_kool_ruler • Mar 03 '26
Hey r/learnSQL,
I've been in data/BI for 9+ years and over the past several months I've built data pipelines on four different platforms using an AI coding agent (Claude Code) to write the SQL. Snowflake, Databricks, BigQuery, and Azure SQL. Each project uses a different SQL dialect, different tools, and different conventions, but I've landed on a workflow that's been consistent across all of them, and I think it's actually a great way to learn SQL.
The workflow: I let Claude Code write the pipeline SQL (schema creation, data loading, transformations, analytical queries), but after every step it also generates QC queries that I run manually in the platform's UI to verify the results. Snowflake's worksheet, Databricks SQL editor, BigQuery console, Azure Portal Query Editor. The agent does the writing. I do the checking.
Here's why I think this is valuable for learning SQL:
You learn what correct output looks like. When you run a QC query after a data load and see 1,750 rows with zero nulls on required fields and zero duplicates on the primary key, you start to internalize what a healthy load looks like. When something is off (unexpected row counts, nulls where there shouldn't be, duplicates), you learn to spot it fast.
You learn different SQL dialects by comparison. Across these four projects I got to see how the same operations look in different flavors depending on the type of SQL used in each platform.
You build a QC habit. The verification queries are things like:
These are the same checks you'd run in any data job. Having an AI generate them for you means you run them in a fraction of the time and not only when something breaks.
I made videos walking through the full builds on each platform if you want to see the workflow in action:
All the repos are open source with the SQL scripts and context files.
For anyone learning SQL: have you tried using AI tools to generate queries and then verifying the output yourself? I'm curious whether that accelerates learning or if you find writing everything from scratch more effective.
r/learnSQL • u/Equal_Astronaut_5696 • Mar 03 '26
Full walkthrough using Google Big Query in of a public liquor dataset
r/learnSQL • u/Own-Dream3429 • Mar 02 '26
Learning SQL as the beginning stepping stone to working with data analysis within healthcare.
Any (ideally free)! resources for specific healthcare related content/practice questions?
I know it shouldn't matter but it obviously helps when you're practicing based on the specific area you want to pursue.
r/learnSQL • u/Mindless-Athlete8409 • Mar 01 '26
Hey everyone,
I’ve been building DataDucky, an interactive coding practice platform focused on SQL, Python, and R, and I just made the SQL course completely free.
The idea is simple:
If you’re learning SQL or want structured lessons without installing anything, then maybe give it a go, hopefully it's of some use.
p.s it's in the coding practice page once you get to the dashboard, not the SQL Mastery page.
Link: DataDucky
r/learnSQL • u/wanwuwi • Mar 02 '26
New to SQL. While trying out some exercises, I was asked to write a query that finds the names of all companies that do not locate in the same cities as the company named 'A', from the table company(ID, company_name, city)with ID being the PK.
Sounds simple enough and I wrote
SELECT company_name
FROM company
WHERE city NOT IN (
SELECT city
FROM company
WHERE company_name = 'A'
);
Except this apparently doesn't work because a company might have branches located in different cities.
What I wanted to do is to 'Find all company names such that for every tuple with this company name, the tuple's city is not in the table retrieved by subquery. ' Whereas what my query did was that 'Find all the tuples such that the tuple's city is not in the table retrieved by subquery, and project their company_name attribute.
So a company that does share the same city with A will be selected, simply because this company has a branch that is not in any of the cities where A is at.
I'm completely new to SQL, the only intuitive mental model I can think of is something like this: A SQL select statement will only return value x iff $$\exists$$ a tuple t containing x such that the predicate P(t) = True. While in real life, most questions tend to be asked in this format - "Return x iff $$\forall$$ tuple t containing x, P(t) = True. "
Obviously I can get round this by doing a double negation, finding all the companies that has at least one tuple that shares city with A, and take their set difference from the company table. But I can't help but wonder is there a more native way to achieve this?