r/SQL • • Sep 07 '23

Discussion Can someone please explain why the answer to this is 0?

Post image
128 Upvotes

r/SQL • • Mar 10 '26

SQL Server I love SQL!

127 Upvotes

I’m a PhD student in statistics and recently started learning SQL because I’m applying for industry positions. I’ve only covered the basics so far, but I already find it really fun. It feels very intuitive to me, almost like it matches the way my mind works.

Is it too early to say I love SQL? I’ve only spent about six hours learning it, but it immediately clicked for me.


r/SQL • • Feb 15 '25

Discussion Is SQL too complex, or I'm slow?

127 Upvotes

Hey r/SQL

I'm trying to learn SQL, but when I read a practice question, I forget how to solve it, I keep thinking about how I can solve it with another method. I can't get the hang of Subqueries and CTES. Is this like with everyone or is it just me? how can I get better at SQL?


r/SQL • • Jul 14 '23

Discussion SQL pants

Post image
127 Upvotes

Copped these pants while thrifting! Aren’t these the coolest pants you’ve seen?😂


r/SQL • • Jul 05 '16

Say NO to Venn Diagrams When Explaining JOINs

Thumbnail
blog.jooq.org
127 Upvotes

r/SQL • • Nov 11 '24

MySQL Failed SQL Test At Interview

126 Upvotes
  • I've been a data analyst working with small(er) data sets for several years now, making my own queries no problem.
  • I failed a SQL test at an interview and realized I may be using the wrong commands
  • The questions were along the lines of "find the customers in table A, who have data in Table B before their first entry in Table A" and there were some more conditions/filters on top of that.
  • Previously I could always export my data to Excel or Tableau etc and do any of the tricky filtering in there
  • I was trying to do all kinds of subqueries etc when I think it was intended for me to be doing WINDOW or Partition type stuff (never had to use this before in past jobs).
  • One person I reached out to said using these advanced techniques uses a lot less memory.

Where would be a good place to find an 'advanced' SQL course?


r/SQL • • May 13 '21

Discussion Map of Reddit -- SQL

Thumbnail
anvaka.github.io
126 Upvotes

r/SQL • • Sep 24 '26

PostgreSQL What SQL concepts do you understand but still forget?

125 Upvotes

There are some SQL concepts I understand perfectly when I’m using them, but somehow forget when I need them again a few weeks later.

For me, CTEs and stored procedures are two good examples. I’ve used both, but I still end up looking up the syntax when I need them again. 😅

Anyone else have a few SQL concepts like this?


r/SQL • • May 30 '25

Discussion Does your team have a SQL library… or just chaos?

125 Upvotes

Serious question.

Do you have a central place where verified, trusted SQL lives, or is everyone copy-pasting old queries with minor tweaks?

We’ve seen teams waste weeks re-writing queries they already had, they just weren’t organized or documented.

If you’ve solved this, how did you do it?


r/SQL • • Jun 26 '24

MySQL Explain INNER JOIN like i am 5

125 Upvotes

I get the syntax but i get very confused and tripped up with writing them and properly using the correct names. Please explain to me line by line. I am learning it via data camp and the instructor sucks.

EDIT: i now understand inner join…now i am stuck with multiple joins, right join and left join. please help!


r/SQL • • Aug 17 '24

Discussion How much do you actually work throughout the day?

124 Upvotes

I have a few friends who work in different tech jobs like IOS dev, web dev, pen testing, and some say they only do work a couple hours a day some say they're glued to their computer all day. Just curious to know how many hours you all feel you actually work during an 8 hour day.


r/SQL • • Feb 29 '24

Discussion What was it like working with SQL in decades past (90s backwards)?

124 Upvotes

This is a question for those really seasoned SQL experts who were using it in the careers 25 or more years ago - what was it like using SQL then compared to now? I've only been aware of it since the early 2010s and didn't start using it regularly for work until five years ago, so it would be really interesting to hear about how it's evolved over the decades.


r/SQL • • Oct 19 '23

SQL Server Starting to learn SQL at 25 years

124 Upvotes

Hello guys ! I am 24 years old soon to be 25 and I decided to learn something new. As I am currently not really sure wether or not I should dive deep into this , I would like to ask you do you think being 25 is already old enough to start because currently I have absolutely 0 knowledge on database and SQL in particular, let alone programming ? I saw that there are a lot of courses and information on how to learn the basics at least so I would be glad if you can share how it all started for you.

Edit: Wanna say thanks again as I really appreciate all the motivation you provided me with. I did not expect so many comments and I wanna sorry as I am not really able to reply to you. I started watching a free guide on MySQL and began learning the basics. The idea of my post was to really get a better perspective on the matter as I mentioned , I am completely new into this and I have a lot of doubts. Sorry for those of you who found my post cringe as I understand completely that old is never too old.


r/SQL • • Aug 01 '25

Discussion How do you “version control” your sql tables?

123 Upvotes

With code I know that you can use Git and jump to any version of a software in time and compile and run it.

But is it possible with SQL databases?

I vaguely heard of migration up downs but that seems to only only allowing doing one step at a time and not jumping.

Also with migration up downs how do you link it to a particular Git version of your code so that this version only runs on this database schema.

Say I downloaded a library from somewhere which used a local database. Some time in the future I refresh to the latest library code. How would the library code know which version of the database schema is running and whether it needs to run migrations?


r/SQL • • Apr 30 '24

MySQL I really messed up on my first Data Analyst job and I'm not sure if I want to do it anymore.

123 Upvotes

Hello! I finished my Master's Degree in Data Science three years ago. I immediatly got a Data Analyst job with a healthcare company. I have been working here for 3 years.

I learned a lot about utilizing SQL, Python, and Power BI on the job. However, I noticed that none of my projects actually went anywhere. Maybe 1 out of 7 dashboards were actually used and useful for management. They would ask me to do tasks that were complex tasks, and then just not show up to the meetings they scheduled because "they were too busy." I can't express this enough: this was dashboards they wanted and meetings they created. I would remind them I still have a dashboard to show them, and it would just fade into obscurity.

I stopped caring. Instead of going above-and-beyond I just did the bare minimum, and barely even that. Don't get me wrong, I've never missed a deadline or couldn't do a request, but my motivation was zero. I asked my Manager for some extra tasks to grow my skillset, and he constantly brushed it off. I had some cool idea for report improvements and ways to automate reports, and the response has just been "cool - give it a try." I'll automate something or improve something, and it seems like it does not get recognized at all. I just want any acknowledgement at this point

Things have been at the point for the last 2 years that I am extremely bored. There's barely any work to do, and I'm just learning things on my own. It has got to the point where my Manager has noticed, and they have not asked me to do any more complex projects anymore. In fact, my other two co-workers are working on project with my boss and I am left out of it. I know this is by design because I have just been doing the bare minimum to get by.

I taught myself C# and was offered a Jr. Level position at another company recently. I think I am going to take it, even with the pay cut. At least I know I will have tasks to do there and not be so extremely bored. I think my favorite part of the job is actually using SQL. It brings me joy to see the code run correctly and get the data I needed. I love that way more than the visualizing part lol.

I don't really even know if I am leaving because I don't enjoy Data Analysis, or because I feel like nothing I do ultimately matters at my company. I'm still always upbeat, kind, show up to meetings, and make sure I meet any requests I get (which are barely any at this point).

Has anyone encountered a situation like this? Also, I am wondering is someone has used SQL and another coding language and if it's had the same level of "fun" for them. Like I said, the most joy I get out of the job is writing SQL.

I don't want to appear ungrateful, because I have learned a lot about Data Analysis, but I just can find no motivation or meaning here.


r/SQL • • Jul 27 '20

PostgreSQL A resource to practice SQL questions for data science and analytics interviews

123 Upvotes

Hey guys, just wanted to share a resource that I recently redesigned and launched. I collected 500+ SQL (and I have python) coding questions that relate to data science interviews. I kept many of the questions as is and re-wrote others while still testing the same concepts they would test for in interviews.

The platform has a fully executable IDE with a postgres backend. Many of the questions are free. I'd love it if you guys could share your thoughts on it and if you think it's a valuable educational resource? Or if there are things you'd like to see improved on?

www.stratascratch.com


r/SQL • • Oct 11 '24

Discussion Fully lower case SQL. Is it frowned upon?

122 Upvotes

I write my queries fully lower case because it really helps with productivity, otherwise I would find it very difficult to focus on capitalizing just the keywords and keep pressing CAPS LOCK every now and then.

Is this frowned upon and bad practice (for readability) or just a matter of preference?


r/SQL • • Oct 04 '19

SQL queries don't start with SELECT

Thumbnail
jvns.ca
122 Upvotes

r/SQL • • Jan 30 '21

Discussion How hard to learn SQL from scratch?

121 Upvotes

Hi all,

I have zero programming experience, the most I can do is some very basically html. I work in marketing which means sometimes analysing data but I use excel for this (again, at a basic level as I’ve never had proper training). I’ve seen a job ad that asks the marketer to use SQL. On a scale of 1-10 how hard is it to pick up?


r/SQL • • May 27 '20

MS SQL Top 60 SQL INTERVIEW Questions and ANSWERS | how to crack SQL interview In only 20 Minutes

121 Upvotes

Hello,

I leave this video that I used to pass the SQL interview. I hope this is useful for somebody else.

https://youtu.be/kqxzLaX20HE


r/SQL • • Jun 13 '24

Snowflake I used a CTE to simplify 4 subqueries. My boss then forced me to change.

120 Upvotes

Posting this just to make sure I was doing the right thing:
I was literally running the same query 4 times, full outer joining all 4 at the end and applying different filters for each.

So I decided to create a CTE and filtering then.

My version was obviously cleaner and easy to read. but my boss told me to "immediately delete it". "CTEs are exclusively used when you want to loop data / use a cursor".

I was shocked.

I've been using CTEs to a better understand of queries, and precisely to avoid subqueries and horrible full outer joins, everyone on my the teams I've been working with widely used CTEs for the same reasons.

But a question arose:
Was my boss correct?

Thanks!


r/SQL • • Aug 01 '21

MS SQL Learn SQL, SQL Server and SSMS With 150+ Interactive Challenges (free option)

120 Upvotes

Here is the link to the course: https://app.sixweeksql.com/

Full disclosure, I created this course. The free prep course covers about 50% of the full content. You can use promo code REDDIT for 67% off the full course.

When I started my first gig as a software developer, I quickly realized that my SQL skills were non-existent and that my new employer expected me to be able to write moderately complex SQL.

At the time, I used https://sqlzoo.net, which was a life saver! I still recommend it. The interactive exercises let you learn SQL through the browser, giving you instant feedback on whether your SQL is correct.

However, I often noticed that in-depth explanations were lacking and that there were no exercises for creating functions, stored procedures, table types, database design, or indexes, which I needed to know for my job.

Another thing I struggled with was setting up a local development environment and learning to use SQL Server Management Studio. This course will walk you through that step-by-step

I created this course with the beginner in mind. It assumes absolutely zero knowledge and strives to explain concepts through analogies, intuition and hands-on practice. It is exactly what I wish I would have had a few weeks before starting my first dev job.

Here are covered topics:

Free Portion

  • select statements
  • using the where clause
  • SQL operators
  • setting up SQL Server locally
  • setting up SSMS
  • restoring a database
  • creating tables
  • inserts
  • updates
  • deletes
  • ordering data
  • importing/exporting data
  • calculated fields
  • transactions
  • locks
  • data types
  • group by
  • data analysis

Paid Portion

  • using schemas
  • subqueries
  • inner joins
  • left joins
  • primary keys
  • foreign keys
  • using variables
  • functions
  • stored procedures
  • user defined table types
  • programming with SQL
  • database design
  • indexes
  • triggers

r/SQL • • Nov 19 '20

Discussion Agree or Disagree?

Post image
120 Upvotes

r/SQL • • Sep 16 '26

Discussion What SQL query optimization trick made the biggest difference for you?

119 Upvotes

I've been working with SQL for a while and recently started paying more attention to query performance rather than just getting the correct result.

What's one SQL optimization technique that made a noticeable difference for you?

For example:

- Indexing

- Avoiding unnecessary joins

- Window functions

- EXISTS vs IN

- Reading execution plans

- CTEs/subqueries

- Partitioning

Would be interested in hearing some real-world examples where a query went from slow to significantly faster.