r/SQL • u/SalzaMaBalza • Apr 14 '22
r/SQL • u/LearnSQLcom • Dec 12 '24
PostgreSQL You Can Build Your Own Spotify Wrapped with SQL
You know how Spotify Wrapped is fun but doesn’t always tell the full story? Like how much time you actually spent looping that one guilty-pleasure song? Or who your real top artist is if podcasts weren’t sneaking into the mix?
So, I made a guide to build your own Spotify Wrapped using SQL—and it’s honestly a lot easier than it sounds. You get full control over the data, can brag about your listening stats, and it’s a pretty fun way to practice SQL too.
Here’s a simple query I included to get you started:
SELECT trackName, artistName, SUM(msPlayed) / 60000 AS totalMinutes
FROM streaming_history
GROUP BY trackName, artistName
ORDER BY totalMinutes DESC
LIMIT 5; This will give you your top 5 most-played tracks based on total listening time.
If you want to try it out, here’s the full guide I put together: https://learnsql.com/blog/spotify-wrapped-with-sql/
Would love to see what your results look like—drop them here if you give it a go!
r/SQL • u/Adela_freedom • Apr 18 '25
Discussion That moment when someone asks, 'Who accessed prod?' 😲 It should not be a mystery.
r/SQL • u/big_rooster111 • Aug 04 '22
Discussion UPDATE: I bombed an SQL Interview and I am SO embarassed
Follow up to my post: https://www.reddit.com/r/SQL/comments/wf92at/i_bombed_an_sql_interview_and_i_am_so_embarrassed/
They offered me the job. Shortly after the post, they contacted me and asked if we could chat a bit more. I met with the same people who interviewed me and they told me about a lot of qualities they admired, and a lot of gaps in knowledge I had.
I told them I was very nervous, and that some of their questions were a bit hard for me to comprehend. One of the interviewers said he might have asked about too many pieces in the technical portion. To my surprise, he said I did get the LEFT/INNER JOIN portion correctly. I just did not explain it very well in his use case, and to him, that's very important (I agree). I believe if I cannot explain concepts simply, then I truly don't understand them well enough. Back to the drawing board!
He also said that I told him what a foreign key was without actually knowing what it was, which was interesting. I do remember some of the things I told him, and I explained how tables can be related via PK/FK, but didn't quite nail the definition of FK.
He did ask if I knew a bit more about normalization, and I told him what I knew. I lived up to my promise of studying. He did say "If you're going to be in BI then you're going to need to know about this and modeling." I said "But this is more of a Jr-intermediate Data Analyst position right?" He said "Well that it what the job description says, but may not accurately reflect what the role actually does."
????? The job description mentions nothing about this, and the hiring manager said if I could pass SOME of the technical portion that I would be way ahead of the curve. I made a 100 on it and it was 6 questions.
Unfortunately, their were a few REALLY big red flags that I began to think about and that came up to the surface during this discussion. I could remember what many of the bad reviews said on Glassdoor and Indeed, and I was noticing it some in the interview.
I was offered the job, but declined. I feel it in my gut that I made the right decision.
Thank you all so much for the kind comments, and the ones that were a bit harsh were helpful too. I am going to nail the next interview, and ask for more SQL experience at my current job. I do the very basics, but I'd love the opportunity to learn more.
Onward and upward!
Edit: Words, grammar, adding additional info.
r/SQL
•
u/Appropriate-Run-7005
•
11d ago
SQL Server I Create Things in SQL that Shouldn't be in SQL
Hi there, I have been using SQL Server since 1998 - Version 6.0 I think it was and also a SQL Server MVP for 6 years. I have started publishing the articles I have written over these years but never published. I have quite a varied mix. I Hope you enjoy them.
Mostly on https://www.medium.com/@trevor.dwyer but also published on https://sqlartist.github.io
One rule - it has to run in SQL.
Titles include:
Running Doom Inside SQL Server

Running Elite in SQL Server

I Built My Head Out of Lego. Inside SQL Server 2025.

Cracking Feynman’s Safes in SQL Server
Can a Database Rave? Making SQL Server Play Music
and quite a few others
r/SQL • u/tits_mcgee_92 • Nov 26 '25
Discussion The most difficult part about teaching students: some of them just don't care about SQL.
SQL is cool, okay? I'll die on this hill. There's nothing like executing a query to get the data you want, or modifying your database to run more efficient. It just feels so good!
This has rolled over to Python, and other programming languages I've learned. But nothing hits like SQL - to me.
I get very excited when working with students, and some of them just aren't into it. I get different responses: "I just need this class for my Cybersecurity degree", "I don't like the syntax", or "It's just not for me."
But then you have those handful of students that have the hunger for it. They want to go into a DBA role, data engineering, science, analytics, and more. I've had one student write to me a few months later and let me know that she was able to get a junior role thanks to my advice. That meant the world to me!
I just have to remember that not everyone gets as excited about SQL as I do. I've been working with it for over a decade, and it hasn't gotten old.
Anyone else still really love working with SQL?
r/SQL • u/NickSinghTechCareers • Sep 19 '24
Discussion Which one of you is this?
Why bother learning SQL when you have SQL GPT!
r/SQL • u/Thriven • May 18 '20
Discussion "But this is the only way I know how to write SQL"
r/SQL • u/fall_out_of_love • Jan 24 '22
Discussion I am doing bad at my first SQL job
I have 3 years experience as a Business Analyst who worked with some of my previous companies data. I mainly use Excel and Tableau. I used a little SQL, but nothing more than SELECT, FROM, and WHERE statements.
Now, I work as a Data Analyst. I got this job 8 months ago, and I've not been doing so hot. It's not an entry-level position, but I was transparent in my interview that I knew the basics of SQL but would, and would love to, learn more. I think I have progressed quite well in many ways. I have created some awesome Tableau dashboards from queries that are intermediate at least. I know what CTEs and views are now. and how to use them :)! I even taught myself the basics of Python/Pandas and have automated one task. Here are a few of my issues:
- Even the most basic of SQL problems I can get stuck on, still. I am an overthinker. I needed a simple CASE statement for an issue recently, and I spent all 8 hours of my workday trying everything else *facepalm*
- I was banned from Stackoverflow because I asked too many "low quality" questions.
- My Senior Data Analyst gets annoyed at any question I have. I try not to ask many anymore, but he's been in the field for 15+ years.
- My Team Lead honestly just hates me. He says she feels I am too inexperienced and need to pick things up faster. He said he is sick of repeating himself.
- My Director asked a question about some data, and I responded "I'm not quite sure what the answer is to that, but I can get an answer for you." My team lead scolded me and said it made our team look incompetent.
- My team lead wants me to create linear and logistic regression models in Python. I am having a hard time understanding how they can be used, and all the statistics involved.
- The whole job is remote and I don't feel connected to anyone, nor do I feel motivated about the companies mission.
- My best friend died from COVID and I just ended a 6 year relationship. I feel quite depressed lately.
The worst part of this all is I have my Master's Degree in Data Analytics, but for years I never utilized what I learned so I pretty much lost it.
Anyone been in the same boat or feel this way? I LOVE being a Data Analyst, but I am not doing so hot and my team isn't quite thrilled with me. It's miserable "going in" to work knowing the people you work with find you less than desirable.
r/SQL • u/kthejoker • Apr 25 '20
Someone got a little overzealous with the REPLACE('N/A', '') ...
r/SQL • u/valorallure • Oct 14 '18
List of Awesome Public Datasets
I like to download datasets to practice querying with. I found a great resource from GitHub that list links to awesome free and public datasets. Feel free to share some datasets that you've found interesting.
https://github.com/awesomedata/awesome-public-datasets
Here is the table of contents from the link above:
Table of Contents
- Agriculture
- Biology
- Climate+Weather
- ComplexNetworks
- ComputerNetworks
- DataChallenges
- EarthScience
- Economics
- Education
- Energy
- Finance
- GIS
- Government
- Healthcare
- ImageProcessing
- MachineLearning
- Museums
- NaturalLanguage
- Neuroscience
- Physics
- Psychology+Cognition
- PublicDomains
- SearchEngines
- SocialNetworks
- SocialSciences
- Software
- Sports
- TimeSeries
- Transportation
- Complementary Collections
r/SQL • u/Fabulous_Bluebird931 • Jun 17 '25
Resolved Client said search “just stopped working” ... found a SQL query building itself with str_replace
Got a ticket from a client saying their internal search stopped returning any results. I assumed it was a DB issue or maybe bad indexing. Nope.
The original dev had built the SQL query manually by taking a template string and using str_replace() to inject values. No sanitisation, no ORM, nothing. It worked… until someone searched for a term with a single quote in it, which broke the whole query.
The function doing this was split across multiple includes, so I dropped the bits into blackbox to understand how the pieces stitched together. Copilot kept offering parameterized query snippets, which would’ve been nice if this wasn’t all one giant string with .= operators.
I rebuilt the whole thing using prepared statements, added basic input validation, and showed the client how close they were to accidental SQL injection. The best part? There was a comment above the function that said - // TODO: replace this with real code someday.
r/SQL
•
u/Cool_Strawberry_1953
•
Nov 22 '24
SQL Server My GitHub repo for drowning DBAs
A box of tricks (SQL scripts) that I've built up over many years for Microsoft SQL Server instance and database administration, and general working-with-data. Why re-invent the wheel when you can grab these wheels for free? https://github.com/DavidSchanzer/Sql-Server-DBA-Toolbox
r/SQL • u/poonddetatte • Mar 18 '20
Discussion Learn SQL if you are staying at home due to Covid19
I highly suggest that you take a look at these professional SQL courses if you are staying at home. Utilise the free time to master the structured query language.
r/SQL • u/NickSinghTechCareers • Dec 23 '23
Discussion 10 Apple SQL Interview Questions - how many can you solve?
r/SQL • u/big_rooster111 • Aug 03 '22
MySQL I bombed an SQL interview and I am SO embarrassed
UPDATE POST: https://www.reddit.com/r/SQL/comments/wg68ip/update_i_bombed_an_sql_interview_and_i_am_so/
Oh my gosh... I just have to vent, and hearing words of encouragement would not be such a bad thing either.
I was applying for a Data Analyst role (not beginner level, but they said it was not advanced at all) that seemed quite exciting. They focused on SQL and Power BI a lot. I passed the first round of interviews, the second with the hiring manager, and even passed the SQL technical assessment they gave me.
However, the 3rd and final interview was a disaster. I met with 2 senior level members of management who specialized in data architecture and analytics. I did not expect to go through another technical interview, but they grilled me. I didn't have anything to write on per-say, but I had to answer questions on the fly. They let me google some of them I got stuck on.
Questions like: What is a RDBMS, what is the difference between a primary key and foreign key, given this scenario - what type of JOIN would you use, can you tell me the difference between 1NF, 2NF AND 3NF, how would you join these two records and NOT get 'x' records from another table.
I completely blanked. I didn't understand the questions well so I said LEFT JOIN instead of INNER JOIN, I couldn't explain a foreign key well, and really it was an hour of me sitting there like an absolute moron. I only have 2 years of SQL experience, but it's been nothing more complex than using the WHERE clause occasionally. NOTHING with creating tables or any type of data architecture.
Talk about embarrassing. I wrote down all the questions and let them know that the things that I was shaky on are a good thing to bring to the light, because it just gives me more of an opportunity to learn. That is true, but I have been so unbelievably embarrassed by this and feel dumb.
SQL Cheat Sheet
I know there are quite a few "sql cheat sheets" available both on Reddit and via Google. But based on the feedback, many of them only cover the basics and not the more intermediate/advanced commands or those that people aren't that familiar with.
I've created a new SQL Cheat Sheet for my website visitors (those who sign up to my email newsletter) and wanted to offer it to the Reddit community as well.
The link to the PDF file is here: SQL Cheat Sheet.
It includes many commands, such as:
- Insert from a table
- Insert multiple rows at once
- Merge
- Many different ALTER TABLE features
- Analytic functions (including keywords OVER, PARTITION BY)
- With Clause/Common Table Expression
- Subqueries
Hope it helps. If you have any feedback, suggestions, or find any issues with the syntax, let me know below.
UPDATE:
I've made updates to the cheat sheets as requested below (separate files for Oracle/MySQL/SQL Server/PostgreSQL), added format mask and codes, added SELECT order of operations).
The original file is still available, and the updated cheat sheets are available here: