/r/learnSQL

Photograph via snooOG

Adventures in the most popular database language

Sequel

/r/learnSQL

38,984 Subscribers

2

INTRODUCTION

Hi, I’m an MSc student learning data analytics. I’ve started with SQL and Excel and want to improve my skills

0 Comments
2024/12/18
00:05 UTC

5

SQL Cheat Sheet question

I have been preparing for tech interviews using this cheat sheet PDF I found on DataLemur.com / LinkedIn from Nick Singh. However, I would like to be able to print it out and have it be readable but the font is too small and the way it is formatted doesn't lend itself to easy manipulations with text sizes. Does anyone know how to make this each half of this 1 page cheat sheet into its own page?

Nick Singh's SQL Cheat Sheet

1 Comment
2024/12/17
23:01 UTC

3

Can you tell me what is wrong with my query?

SELECT w1.id as id
FROM Weather as w1
WHERE w1.id IN 
    (SELECT w2.id FROM Weather as w2
    WHERE DATEDIFF(w1.recordDate, w2.recordDate) = 1
    AND w2.temperature > w1.temperature);

Input

Weather =| id | recordDate | temperature |
| -- | ---------- | ----------- |
| 1  | 2015-01-01 | 10          |
| 2  | 2015-01-02 | 25          |
| 3  | 2015-01-03 | 20          |
| 4  | 2015-01-04 | 30          |

Output
| id |
| -- |
| -- |

Expected
| Id |
| 2  |
| 4  |
4 Comments
2024/12/17
16:42 UTC

91

Awesome SQL Resources for 2025

I don’t know about you, but I’ve wasted so much time trying to find SQL resources that are actually useful. You search for something simple, and suddenly you’re neck-deep in outdated tutorials, half-baked blog posts, or YouTube videos that take 10 minutes to get to the point.

So, I decided to do something about it. I spent some time collecting the good stuff—articles, cheat sheets, tools, and YouTube channels—and threw it all into one GitHub repo. It’s basically a "SQL survival kit" for 2025.

Here’s what I put in there:

  • 50+ solid articles that actually teach you something.
  • 20 cookbooks with practical SQL examples for when you need solutions, not theory.
  • Cheat sheets (because no one remembers everything).
  • Tools to work with SQL.
  • YouTube channels that I recommand and are not waste of time.

This list is for anyone working with SQL, whether you’re just starting or already knee-deep in data.

It’s all here: Awesome SQL Resources for 2025.

Let me know if this is helpful.

5 Comments
2024/12/17
13:27 UTC

3

New to SQL

SQL gawds, I humbly request your guidance, on beginning the journey. I am trying to learn SQL and would appreciate your suggestions on resources that cover:

  1. Where to learn
  2. How to download it to system to practice (it sounded super confusing when I heard someone say it on Youtube 😵‍💫)
  3. Certifications?

Any and all assistance is much appreciated. I need to learn it as part of just about anything I want to do in data.

17 Comments
2024/12/17
05:19 UTC

0

helpful websites or ai asisstant

is there any assistants (ai or some website) where i can copy my tables into and they help me write queries for it? im really in the begining of learning sql so this would be helpful. Or any tipps with mysql in xampp?

1 Comment
2024/12/16
15:36 UTC

36

How do I continue learning SQL?

Hello, I just finished the SQL for Data Science Course by UC Davis in Coursera.

It seemed like an elementary course, which was great since I had 0 experience in SQL.

However, now I am wondering how I should continue learning SQL? Should I practice it? How?

Thank you very much

14 Comments
2024/12/16
09:59 UTC

2

Using SQL with the stock market tutorial created by a sql developer and stock trader. Step by Step guide.

Let me know what you guys think. I’m a SWL developer and stock trader at heart.

0 Comments
2024/12/16
00:24 UTC

5

Got marked wrong for saying SELECT is 'the SQL keyword for querying' in my DS exam - am I wrong?

Quick sanity check needed regarding a Data Science exam question I'm disputing.

Question asked: "The SQL keyword for filtering after grouping is (i), and the SQL keyword for querying is (ii)."

I put SELECT for (ii) but was marked wrong. Prof says WHERE is correct because "SELECT is for specifying a subset of columns; querying is the act of specifying a subset of rows."

However, PostgreSQL's documentation literally states: "The process of retrieving or the command to retrieve data from a database is called a query. In SQL the SELECT command is used to specify queries."

When I disputed it, prof mentioned it was meant to parallel Pandas concepts from lecture, but the question itself made no mention of Pandas or specifically asking about row filtering.

I get that WHERE filters rows. But if you're asked "what's the SQL keyword for querying" with no other context, isn't SELECT a valid answer? The question doesn't specify row filtering anywhere.

I'm 1.3 points from an A in the course, so this isn't just me being pedantic. Would love to hear what other DS folks think.

Additional context: This was in an intro DS course where we covered both Pandas and SQL.

5 Comments
2024/12/15
23:50 UTC

3

Looking for feedback: Learn SQL through an AI instructor!

Hi there,

I'm a co-founder for Uphop.ai and we are building a new way of learning SQL and other skills through AI. A major challenge with online learning today is that you can't get real-time support when you have questions or want to go deeper on a concept being discussed. It's also hard to keep engaged with hours and hours of passive recorded videos. We believe AI can help make learning fun and engaging.

We've built a set of AI instructor-led lessons on SQL and you can try it out here for free. Appreciate any feedback or inputs and thanks for your support! 🙏

6 Comments
2024/12/15
13:00 UTC

1

Syntax Written Order vs. Query Processing Order

https://preview.redd.it/n7qn5tf7to6e1.png?width=538&format=png&auto=webp&s=fb5b6b858c06e109df24665a4700b136e18a8e4a

A good friend of my is currently building a SQL course. He shared this image with me from an article he is writing about SQL order of operations. I found it very helpful to distinguish between the written order and the query process order in SQL.

1 Comment
2024/12/13
21:55 UTC

5

Master SELECT Statements with a Fun Movie Database

Hi everyone! If you've just started with SQL and want to solidify your basics using a fun and interesting database, I’ve got the perfect resource for you.

I’ve created a video featuring 30 practical and engaging tasks to help you build confidence with SELECT statements. By the end, you’ll feel ready to tackle more advanced SQL concepts.

The database is currently available for SQL Server users, but I plan to release a PostgreSQL version if there’s enough demand.

To be able to receive the database file, simply fill out the form linked in the video description. If you'd like additional advanced puzzles on the same database, check the relevant box while filling out the form.

Enjoy, and feel free to share your progress or feedback!

The Channel

1 Comment
2024/12/13
09:04 UTC

50

SQL Basics Cheat Sheet For You Guys!

If you’re learning SQL or just need a quick refresher sometimes, you’ve gotta check out this Free SQL Cheat Sheet. It’s clean, super easy to follow, and has all the basics—SELECT, JOIN, GROUP BY, all that stuff—without any unnecessary fluff.

https://preview.redd.it/haxwkp0byh6e1.png?width=977&format=png&auto=webp&s=19ac0c017a883fdbc168a202018e0b8ff149d395

Here’s the link: SQL Basics Cheat Sheet

We made this because, honestly, who remembers everything off the top of their head? Bookmark it, pin it, whatever—trust me, it’s worth it.

Do you use any cheat sheets or tricks for SQL? Always looking for new ways to make life easier.

7 Comments
2024/12/12
22:49 UTC

8

Best PDFs, Apps, Websites or Books to learn SQL (in german)

I would like to learn SQL as I work in customer data management. Can anyone recommend PDFs, Apps, Websites or books for learning SQL? If possible in German. Learnsql.de is unfortunately not for free.

3 Comments
2024/12/12
19:55 UTC

4

ORDER BY sorts twice for some reason

I am a n00b at this...anything wrong with my syntax that would cause this to order by two separate times? MJ should be at the top with the last name in the list being Kevin Salvadori.

https://preview.redd.it/up73k7worb6e1.png?width=429&format=png&auto=webp&s=5b76ce990d38498257c90b441c57fb83a188ae9b

4 Comments
2024/12/12
02:03 UTC

29

Netflix Data and SQL. See Your Real Binge Stats

You guys really liked my last post about creating a custom Spotify Wrapped with SQL, so I thought—why stop there? This time, let’s tackle Netflix!

https://preview.redd.it/gfntsndea86e1.png?width=1000&format=png&auto=webp&s=49ba19f4bf980df0077458651ccf61b9a15d56ea

Ever wonder how much time you really spent bingeing your favorite shows? Or which series kept you glued to the screen the most? Netflix doesn’t give you a Wrapped like Spotify, but the good news is—you can make your own!

Step 1: Download your Netflix watch history (it’s super easy).
Step 2: Use SQL to analyze it.
Step 3: Discover your top shows, total hours watched, and other fun stats.

Here’s an example query to find your top 5 most-watched titles by viewing time:

SELECT title, COUNT(*) AS totalViews  
FROM viewing_activity  
GROUP BY title  
ORDER BY totalViews DESC  
LIMIT 5;  

Check out the full step-by-step guide here: https://learnsql.com/blog/netflix-wrapped-with-sql/.

It’s a fun project to practice SQL while turning your watch history into insights.
What’s your real most-watched show? Share your results! 🎬

3 Comments
2024/12/11
14:19 UTC

9

best sql server book that covers everything, from beginner to expert?

I am beginner to intermediate level software engineer with day to day work on sql server along with .net ,

Can someone please suggest me book for sql server to make my skills to next level , I like to read tech books cover to cover

4 Comments
2024/12/10
21:12 UTC

91

Make Your Own Spotify Wrapped With SQL

You know how Spotify Wrapped drops every year, and everyone posts their top tracks, artists, and listening stats? It’s fun, but let’s be honest—sometimes you want more than just what Spotify decides to show you. Like, how much of your life did you waste listening to that one guilty-pleasure song? Or who really was your top artist if Spotify didn’t sneak in podcasts?

https://preview.redd.it/vdb3ufno416e1.png?width=1920&format=png&auto=webp&s=7714a5b096cda213ae4a3d134aa62a36ea1b43d3

If you’ve ever wanted to nerd out with your own music data, I’ve got something cool for you: build your own Spotify Wrapped using SQL. It's not as complicated as it sounds. You’ll get full control over the insights, bragging rights, and a legit reason to practice SQL while making charts for fun.

For example This query sums up the time you spent on each track and sorts them in descending order.

SELECT trackName, artistName, SUM(msPlayed) / 60000 AS totalMinutes
FROM streaming_history
GROUP BY trackName, artistName
ORDER BY totalMinutes DESC
LIMIT 5;

Check out the full guide—from downloading your data to visualizing it: https://learnsql.com/blog/spotify-wrapped-with-sql/

I’d love to see your results—share them here!

8 Comments
2024/12/10
14:18 UTC

3

Please help me fix this error.

import mysql.connector as sql

ModuleNotFoundError: No module named 'mysql'

2 Comments
2024/12/09
17:39 UTC

13

More free coupons to SQL course on the condition that you spread the knowledge ...

3 Comments
2024/12/08
18:22 UTC

0

Best project based data engineering course?

Need recommendations for online data engineering courses which will have a real life project.

Please help

0 Comments
2024/12/08
16:25 UTC

0

How to install SQL on macbook

Hi there,

I need steps on how to install sql for my macbook version, it's macos bigsur 11.6 apple chip. I tried but the myself website only works for newer versions of macbook.

Thanks!

0 Comments
2024/12/08
01:24 UTC

10

Losing rows with COALESCE

Hey everyone, I'm working on a query for work and I've found the solution to my issue, but I can't at all understand the reasoning for it. If anyone could help me understand what's happening that would be greatly appreciated. Anyway, the problem is that I seem to be losing rows in my original query that I regain in the second query just by including the columns I use in the coalesce function also outside of the function

My original query with the problem:

SELECT Monday, a.id, FORMAT(COALESCE(a.date,b.date),'yyyy-MM') as Month,

FROM a

LEFT JOIN b on b.anotherid = a.anotherid

and then the query that does not have the issue:

SELECT Monday, a.id, FORMAT(COALESCE(a.date,b.date),'yyyy-MM') as Month, a.date, b.date

FROM a

LEFT JOIN b on b.anotherid = a.anotherid

5 Comments
2024/12/06
15:00 UTC

22

Looking for Feedback: Gamified SQL Learning Platform to Build Daily Habits!

Hello SQL Enthusiasts,

I’ve been working tirelessly on a gamified SQL platform alongside my full-time job, and it’s finally ready to launch! The platform features daily challenges, streaks, and a leaderboard to help you build a 5-minute-a-day habit (Duolingo format) and sharpen your SQL skills.

Your feedback means everything to me. I will keep the current platform free for 3 months for this community as a thank-you. Whether you’re preparing for placements or just love SQL, I’d love for you to try it out and share your thoughts.

Your feedback means the world to me—I’ve poured my heart into this project and truly want to make it better for learners like you. Thank you for your support, and I can’t wait to hear your thoughts! 🙌

Link to the platform - sqlninja.ai

11 Comments
2024/12/05
19:18 UTC

1

need help

It doesn't work when I type 100 instead of 100.0 may I know why

```
SELECT patient_id, weight, height,
case 
when weight / (power(height / 100.0, 2)) >= 30
    then 1
       else 0
    End as isObese
from patients
```
3 Comments
2024/12/05
14:10 UTC

3

End-to-End SQL to Power BI Dasboard Project

0 Comments
2024/12/05
12:28 UTC

Back To Top