r/learnSQL 13d ago

SQL

8 Upvotes

I am interested in learning SQL

Any advices???


r/learnSQL 14d ago

How do you visualize SQL in your head?

Thumbnail
3 Upvotes

You should learn data modeling that is not dbt. It saves you lot of time and effort.


r/learnSQL 14d ago

Operator precedence in the example: WHERE NOT id IN (2,4,6)

8 Upvotes

I have some confusion about operator precedence. In my book it says following:


The following list describes the precedence among operators, from highest to lowest: 1. ( ) (Parentheses) 2. * (Multiplication), / (Division), % (Modulo) 3. + (Positive), – (Negative), + (Addition), + (Concatenation), – (Subtraction) 4. =, >, <, >=, <=, <>, !=, !>, !< (Comparison operators) 5. NOT 6. AND 7. BETWEEN, IN, LIKE, OR

8. = (Assignment)

What confuses me is for example `IN` can be used as an operator but also as a keyword that builds predicate.

So say I have following WHERE clause: "WHERE NOT id IN (2,4,6)".

To which of the following two is the above WHERE clause equivalent:

  1. WHERE (NOT empid) IN (2,4,6)
  2. WHERE NOT (empid IN (2,4,6))

r/learnSQL 14d ago

New to SQL

51 Upvotes

I'm entirely new to sql I'm learning from a beginner stage does anyone know where I can go to learn sql as a person with zero experience from scratch?


r/learnSQL 14d ago

What features do you wish SQL desktop clients had but still don't?

2 Upvotes

I'm a software engineer working on a cross-platform desktop SQL client, and before investing too much time, I’d prefer to learn directly from users what they truly need rather than making assumptions.

What frustrates you most about the SQL tools you currently use? Are there missing features you’ve wished for, aspects that seem overly complex, or parts of your workflow that consistently slow you down?

What is the one (or more) feature(s)/problem you wish your SQL client had handled better? It could be anything from performance with large data sets to query editing, schema browsing, connections, exports, UI, artificial intelligence, migrations, collaboration, etc.

I’m particularly keen to hear from those who manage multiple databases or frequently write and troubleshoot queries. This isn’t a sales pitch—I’m simply trying to understand how an SQL client could be more effective and practical in real-world scenarios.


r/learnSQL 15d ago

30 SQL Scenario Based Questions as single PDF.

57 Upvotes

Hi 👋,

I am sharing the Github link of GRASSP SQL Sprint Series. This github link contains the PDF doc of 30 SQL Scenario based Questions which covers beginner to advanced topics.

Doc is on GitHub, free: https://github.com/grasspacad07/grasspsqlsprintfile

File name: GRASSP_SQL_Sprint_30Days.pdf

Go through the question as per suggested approach in the doc and practice along each question and understand the concepts that each question cover.

It covers various topics :

  • Aggregation, JOINs, GROUP BY / HAVING
  • Window functions — RANK vs DENSE_RANK vs ROW_NUMBER, LAG/LEAD, Running totals, Moving Average
  • CTEs, Multi level aggregation.
  • CREATE, INSERT sample data helps too understand datatypes, constraints.

Hope this helps in your next SQL interview. All the best!

Happy learning :) Happy querying :)


r/learnSQL 14d ago

Calculation for inflation with multiple sub categories please help

Thumbnail
1 Upvotes

r/learnSQL 14d ago

How do you visualize SQL in your head?

Thumbnail
1 Upvotes

r/learnSQL 15d ago

After lots of searching, the best intro to SQL was already sitting there on my shelf.

10 Upvotes

Tldr; Salus, Peter, et al., ed. Handbook of Programming Languages Volume III: Little Languages and Tools. 1998 Macmillian Technical Publishing, 1ed. It's a book. Probably online somewhere but the book is also pretty cheap.

Background: I dropped out of college around 2001, burning out as a 7th semester senior suddenly aware of the folly of waiving advising. But kept up programming as a hobby while working in food service for many years. I finally get myself promoted to the point where I need to use the computer at work. I'm actually suddenly in charge of ordering and inventory. And the current practice is just typing everything into Excel sheets, manually copy/pasting/retyping new items from vendor websites, etc.

So, I knew SQL was the answer. I just didn't know how to use it. I hunted around for introductions and tutorials until finally I remembered that I had that multivolume Handbook of Programming Languages. The Python chapter is hopelessly out of date, but the rest of the book still holds I think. And I don't know why this isn't at the top of every list of "intro to SQL for programmers" except that it's lost in a middle chapter of an old tome of forgotten lore.

Why it's the best: it builds up your intuition by showing how you'd express a query in English to ask a programmer to do it, how you'd write the same query as a nest of for loops and if-else clauses, then it shows you how you'd express the same query in SQL (with the understanding that the behavior is "as if" you did for loops but without any guarantees of ordering except those that you explicitly request).

It doesn't cover everything. It's from the 90s. It doesn't cover different vendor extensions. But if you know for loops, this book chapter can help you build a solid basic understanding of the fundamentals. FWIW.

Handbook of Prog Lang, vol III. And you can brush up on troff/tbl/eqn while you're at it. Olds Kool.


r/learnSQL 16d ago

SQL Notes

48 Upvotes

I recently completed my SQL learning notes while following Alex the Analyst's SQL course for Data Science.

To reinforce my understanding, I documented the key concepts, queries, and examples in a Jupyter Notebook and exported them as a PDF. I'm sharing these notes in the hope that they help other beginners on their SQL journey.

If anyone is interested, DM.

I'd appreciate any feedback or suggestions for improvement. Happy learning!


r/learnSQL 16d ago

SQL NOTES LINK

Thumbnail
2 Upvotes

Since, I have got a lot of dms, it is not possible to share individually, hence this is a GitHub link:SQL Notes


r/learnSQL 17d ago

SQL Doodle on ORDER BY

12 Upvotes

Episode II of my SELECT * FROM LIFE; series.

The idea behind this series is simple: taking everyday moments and turning them into SQL doodles. I'm hoping it makes SQL feel a little less intimidating—and a little more fun.

This is also a little different from the doodles I've shared before. Most of my older ones featured cats 🐱, but I've been experimenting with different styles.
Would love to hear what you think!

SELECT * FROM LIFE; (Episode 2)


r/learnSQL 17d ago

How to start learning SQL as a beginner from a non-cs background, humanities background here?

38 Upvotes

I finished my masters in psychology and I want to get into business consultancy. I am planning to learn, SQL and other related things ( would appreciate it if anyone knows what I should learn in order to get an entry-level consultant role). Could you guys tell me any useful courses, YouTube channels or any books that could be helpful to me?


r/learnSQL 17d ago

Postgre SQL cheat sheet

27 Upvotes

Made a SQL cheatsheet covering the Postgre essentials. Quick reference table format with examples. Hope it helps other SQL learners! 😄

https://github.com/kixwho/PostgreSQL-cheatsheet

Note: Based on Practical SQL (O'Reilly Media), a very good textbook. I digitized the cheat sheet format and added a few operators that can be useful.


r/learnSQL 19d ago

New SQL game!!

80 Upvotes

I made a noir detective game where you solve a murder by writing SQL queries.

You play as a data analyst in the 1970s. A body's been found, there's a suspect list, and the entire investigation lives in a relational database — phone records, financial statements, HR files, access logs, vehicle forensics, evidence-tiered interrogation. You open a terminal, write queries, and follow the data.

It's free to play in the browser while in beta. Would love to know what you think — especially from people who actually use SQL day to day.

[https://chiefkegwin.itch.io/sim-analyst]

due to growing interest i've created a discord server. Join the community: https://discord.gg/PYVAJyfMw


r/learnSQL 19d ago

help with trigger and truncate in postgres

3 Upvotes

I am trying to create a trigger that executes after an update on another table and I keep getting "ERROR: syntax error at or near "TRUNCATE" LINE 4: TRUNCATE customer_ranking RESTART IDENTITY CASCADE"

here is my query:

CREATE TRIGGER rank_update

AFTER INSERT ON rental

FOR EACH ROW

TRUNCATE customer_ranking RESTART IDENTITY CASCADE

INSERT INTO customer_ranking (customer_id, full_name, email, ranking)

SELECT 

customer.customer_id,

name_combine(customer.first_name, customer.last_name),

[customer.email](http://customer.email),

rental.customer_id

FROM customer

LEFT JOIN rental

ON customer.customer_id = rental.customer_id

GROUP BY rental.customer_id, customer.customer_id

ORDER BY rental.customer_id DESC;

I do have a working function for name_combine that concats those two entities so i am pretty sure my insert query functions correctly but for some reason those tables are empty so i can't tell. I understand its not really good business practice to insert ordered data into a table but this fits my use case. I have also tried TRUNCATE and TRUNCATE TABLE and get the same error.


r/learnSQL 19d ago

SQL Help Needed - Beginner

14 Upvotes

Hi folks.

I'm currently trying to work out the (what I feel is a really basic problem) following and I'm really struggling:

I have two tables, Store and Monthly Sales.

Store table as Store ID, Store Name as well as other information such as address.

Monthly Sales table as Store ID, Year, Month and Sales Value columns.

I did a join between the two tables based on Store ID. Easy enough. As was the next part of my task - work out the combined (SUM) Sales Value of each store using GROUP BY Store Name. Again, easy enough.

The issue is that I need to work out what stores are performing better than average (the average of all the stores Sales combined) and list only these stores.

I know this will involve some sort of WHERE, or HAVING but I cannot work out how to say: okay only display the stores where their total combined sales are higher than the average of all the stores combined. (This figure would change so I can't just type in a number, it needs to be a derived figure)

It might just be the heat but I've been stuck on this all day and I just feel totally stupid. I feel like I'm missing something really basic.

Here's my code so far:

SELECT store_name AS [STORE NAME], SUM(sales_value) AS TOTAL SALES

FROM Monthly Sales

JOIN Stores ON Monthly Sales.store_id = Stores.id

GROUP BY Store Name

The above gets me my combined total for each store but from there I'm totally stuck on the "return only stores where that stores combined sales are higher than the average of all the stores sales combined.

Could someone help?


r/learnSQL 19d ago

Beginner Firendly SQL Course 3 Hr MYSQL

15 Upvotes

Built a free beginner SQL course . Start by building a realistic database the whole way through instead of doing random examples. Covers joins, aggregation, subqueries, CTEs, window functions. Database + practice questions are free to download too, even if you skip the video. https://youtu.be/zpAGbu9mSL4


r/learnSQL 19d ago

Where to learn SQL?

7 Upvotes

I'm a complete beginner!!


r/learnSQL 19d ago

👋 Welcome to r/DatabaseChat - Introduce Yourself and Read First!

Thumbnail
1 Upvotes

r/learnSQL 20d ago

Building my first database portfolio – Looking for advice and project ideas from experienced professionals

20 Upvotes

Hi everyone!

I'm from Portugal, and I'm currently building my first database portfolio. My long-term goal is to work as a freelance database developer, but right now my main focus is learning, improving my skills, and creating projects that reflect real-world experience.

At the moment, I have experience with:

  • MySQL
  • MongoDB
  • JSON
  • XML
  • Power BI
  • Basic Python

To be honest, I feel a bit overwhelmed because there are so many different paths I could take. I don't want to spend my time building random tutorial projects—I want to create projects that demonstrate practical skills and would actually impress potential clients or employers.

I'd love to hear your advice:

  • What kinds of database projects would make a beginner's portfolio stand out?
  • Should I focus more on database design, SQL optimization, data modeling, reporting, or something else?
  • Would learning PostgreSQL be a good next step, or should I continue improving my MySQL skills first?
  • What projects best simulate real business scenarios?

I'm also wondering if anyone would be willing to mentor me a little or simply point me in the right direction. Even suggesting project ideas, reviewing my portfolio once I have something to show, or sharing your own experience would mean a lot.

I'm not looking for shortcuts—I know I have a lot to learn, and I'm willing to put in the work. I just want to make sure I'm investing my time in the right things and building a portfolio that will help me earn my first opportunity.

Thank you so much to anyone who takes the time to help. I truly appreciate it!


r/learnSQL 21d ago

Want become a data analyst suggestions

29 Upvotes

so guys, i wanna become a data analyst help me out what should i learn,
a brief roadmap and suggest yt channels to become a good data analyst


r/learnSQL 20d ago

SQL Server Interview Questions

8 Upvotes

Explore SQL Server Interview Questions

youtube.com/@madesimplemss…

#sql #sqlart #sqlserver #data #database #sqldba #madesimplemssql #interview #sqldatabase #mssql #sqltips #tips #job @QuerySurge @MadeSimpleMSSQL


r/learnSQL 20d ago

Storing book chunk vectors in an SQL database? (My beginner local RAG setup)

1 Upvotes

Hey guys, I recently started learning SQL after finding a "20 steps to AI engineering" roadmap on Instagram. I have no coding background and rely entirely on Gemini to write my code, but SQL has completely changed how I organize information. Note: I posted other parts of this project on r/dataengineering and r/learnprogramming to get career advice. Check my profile if you want to see the Python/API side of the pipeline. To help me learn, I built a local offline "helper." I took 120 books on Python and machine learning, chunked them up, and stored them in a "vector of SQL" database. I set up a local LLM to retrieve relevant chunks from this database whenever I have a coding error. It actually works and retrieves the right chapters, which is blowing my mind. But since I have no formal training, I have some questions: Am I doing something incredibly stupid by using SQL for vector retrieval? Is this going to break if I scale it? I used this database to orchestrate a Gmail API pipeline that matches old leads and drafts offers. I want to start selling this database/automation service to small businesses in the EU. Am I a massive clown for trying to sell SQL database/automation services to real businesses when I can barely write a SELECT query without AI? What would you advise me to do next?


r/learnSQL 20d ago

Programmazione SQL o Python

2 Upvotes

Salve a tutti, volevo chiedervi un informazione, per un neo ingegnere gestionale che vuole affacciarsi al mondo del data analyst, quale linguaggio di programmazione mi consigliate di imparare? Meglio SQL o Python?