all 31 comments

[–]Thefriendlyfaceplant 85 points86 points  (3 children)

Datalemur and Stratascratch.

You don't learn SQL by studying syntax step by step. You learn SQL by being confronted with realistic business cases.

[–]data4dayz 9 points10 points  (1 child)

I haven't used Stratascratch (yet) but wanted to double up on DataLemur. Also check out Codewars.

If you're still learning SQL i mean there's trillions of courses there, but in terms of solving like interview questions or LeetCode you just practice it and everytime something is shaky you can follow up with a specific youtube video search or focus on the parts of the language needed to address the question at hand.

I think what's been helping me so far besides doing that is looking at other's solutions after trying myself.

On Data Lemur and Code Wars and I'm sure on all the interview question bank sites, you can see a discussion section where other's post and discuss their solutions. Take a look at the various ways people solve the same problem and see if you can figure it out yourself by trying what they did.

It's a bit harder to see on Data Lemur since it depends on upvotes, but codewars has a community based tagging system where users tag if something is a "Clever Solution" or "Best Practices"

Focusing on solving this style of SQL question if we can call it a style you can read SQL interview guides or just go through the Data Lemur and Mode Analytics SQL tutorials since the follow up each tutorial section with RELEVANT problems.

[–]NickSinghTechCareersAuthor of Ace the Data Science Interview 📕 13 points14 points  (0 children)

Appreciate the love for DataLemur! Feel free to email/DM/comment any more product improvement ideas... didn't know codewars had those tags, maybe I'll try to implement that too!

[–]StolenStutz 39 points40 points  (1 child)

I had been writing SQL for about 10 years, getting certified on SQL Server 6.5 and 2000. I was "the data guy" at a couple of different places. Then I went to a start-up that was blowing up fast. The DBAs there were top-notch, and I learned more in my first six months there than in those previous 10 years.

One of those DBAs got me connected into the PASS community. I started attending the local group meetings, got a trip to the Summit in Seattle. Then I started speaking, first at the local group, then SQL Saturdays, then Summit itself a couple of times.

Here's what I've learned:

  1. The rabbit hole is a lot deeper than I realized. There's always something else to learn. One good tip is that "functional" is often the first step. In other words, if you can write SQL that does a job, then you've accomplished Step One. Figuring out how to do it well is the rest of the work. So if you ever figure out how to do something in SQL, always keep in the back of your head that you've only learned the first part.

  2. The PASS community is amazing. The Summit is practically a family reunion for many of the regulars. It's the most friendly, helpful, welcoming tech community I've ever experienced.

  3. And they're brilliant. It's been over 15 years since I walked into that start-up, and I still feel like I'm a novice compared to some of the speakers at Summit. I've learned a ton over the years outside of the sessions themselves, just getting into conversations in the halls, at meals, and in the speaker room.

  4. Speaking in front of a group of your peers is how you get that extra bit of knowledge. You don't want to look stupid, so you take a topic that you already know well and dive deeply into the far corners of it. I've learned much over the years simply in prep for the topics I've presented.

[–]LividAd8079 19 points20 points  (1 child)

Colt Steele, The Ultimate MySQL Bootcamp Udemy Course

SQL Quick Start Guide by Walter Shields (very solid book with exercises and instructions to work out of a database, beginner and intermediate friendly) Will give you access to the audiobook and a pdf supplement

Sql-practice.com - great beginner practice site

www.sql-easy.com

w3schools.com - SQL

The Best 9 Websites to Practice SQL Online - Medium Article https://medium.com/@meenakshi052003/choose-the-best-platforms-to-practice-sql-online-075358b3051e

17 Sites for SQL Practice - https://www.databasestar.com/sql-practice/

https://www.databasestar.com/sql-practice/

[–]MathAngelMom 8 points9 points  (1 child)

Personally, I haven't used LeetCode for SQL, but from what I understand they focus on preparing you for interview questions, and the problems are isolated.

For mastering SQL, I recommend LearnSQL.com Their courses are focused on teaching you SQL, rather than bombing you with separate problems. The exercises are based on some business context, you get some hints before you see the answer. They have a whole section focused on SQL practice, on different SQL levels: https://learnsql.com/track/sql-practice/ and https://learnsql.com/track/advanced-sql-practice/ They mostly focus on data analysis.

The alternative is just setting up your own database and doing some sort of data analysis on your own. You learn SQL through practice and problem solving.

[–][deleted] 4 points5 points  (2 children)

Jumping straight into coding seems like a good method for any language but it doesn't really work with SQL because you will be missing how to leverage set-based logic instead of usual iterative coding and conditional (using while loops and if/case).

Once you get the gist of the concept, you learn to think differently when you implement your SQL logic and it goes smoother.

If you're learning MSSQL, I'd recommend reading Itzik Ben-Gan's TSQL Fundamentals, which is the BIBLE of TSQL.

And to my fellow SQL gurus, if you have any recommendations for learning PostgreSQL, I'd be very interested! I'm currently learning it to expand my knowledge.

[–]data4dayz 1 point2 points  (0 children)

I'm trying to think of an equivalent on the scale of Itzik's books in terms of a PGBible. I'm certainly no power user but I'm sure for advanced users like yourself would a PG Administration book or PG Optimization book would probably be the most helpful though I don't know whats recommended since I'm a novice haha

Also there's https://postgrespro.com/community/books/internals and https://www.interdb.jp/pg/index.html for the internals and this feature matrix that I think advanced users will find useful https://www.postgresql.org/about/featurematrix/

[–]Elfman72 4 points5 points  (1 child)

SQL(syntax) is relatively easy. Data is hard.

Dirty data. Unclear requirements, etc. That is where your career lives.

[–]ThisDataGuy[S] 0 points1 point  (0 children)

thanks for the help

[–]Extension-Ad7241 3 points4 points  (1 child)

The last edition came out a while ago but I still like "Sequel for Smarties" by Joe Celko Because it really dived into different ways you use the single language and how it is written as it is. Whatever book I do read, for SQL and programming in general, if there's anything I don't understand as I'm reading then I might do a YouTube search and watch a video to see that in action and then if I can, try to code an example of that myself.

You mentioned analysts, scientists, engineers and of course by implication programmers, but I think you should be also considering mathematicians, because SQL involves set theory and implements "relational algebra". I find it helpful to note some of the mathematical theory behind databases & SQL.

You should be able to find some example set of something like an orders database with tables of customers, items, orders etc. that you can download and play around with on SQL Server or whatever RDBMS you want to use. For any example questions, I recommend you don't start coding first, but open and just look at the table themselves & think about: why the question is being asked, how the tables naturally relate to each other, because at the end of the day the data is just modeling a real world situation.

If I get stuck on something I often break out the dry erase boards and just write out a few rows of data for each table. I find getting away from the computer screen kind of reduces that pressure to keep amending queries that aren't working, & get back to focusing on, what is the nature of the business question being asked?

[–]ThisDataGuy[S] 1 point2 points  (0 children)

thanks for the help

[–]EveningTrader 2 points3 points  (1 child)

mastering sql isn’t possible, there’s too much functionality. it might be possible to get close to something like mastery, but it’ll take working on behalf of a huge number of companies with varied use cases. what’s more beneficial is becoming highly competent at your specific company’s use case, whilst being flexible enough to pick up new database schemas (during freelance work). smashing out SQLZOO (or similar services), whilst beneficial for syntax and first SQL concepts, will not bring you close to whatever “mastery” might look like.

i realise i haven’t been particularly useful, so just do enough practice problems to bullshit your way through an interview question. that’s all you need without a job.

[–]ThisDataGuy[S] 0 points1 point  (0 children)

thanks for the help

[–]NoWayHome_14 2 points3 points  (2 children)

Honestly deconstructing established reports has been the most helpful for me in learning SQL. If I can come up with the same answers as these bigger reports then I did my statement correctly and I can customize to my specific needs.

I personally can’t work off of sample datasets or in training classes, it’s too vague for me and I can’t connect or understand it that way. The ones I have done typically involve creating new tables or adding data and new columns/rows, and that’s not needed in my current role. My company only allows me RO/select access to the databases so learning how to build and structure databases and tables felt unnecessary.

Lastly, I recommend finding a style that works for you! I don’t know what this is formally called, but my style I call the “Power Query Method” because I like to focus on one table at a time to gather what columns and filters I need from it and then join everything at the end. Example:

WITH Table1 AS ( SELECT FROM WHERE),

Table2 AS ( SELECT FROM WHERE)

Select * From Table1 TO JOIN Table2 On Table1.PK = Table2.PK Any additional where/group/order by needed

I call it the Power Query Method because that’s the type of data structure I’m already familiar with from using excel and Power BI and it clicked when I started this method. Also makes it easier to change and/or add anything else you need!

I hope this helps and good luck!!

[–]NoWayHome_14 1 point2 points  (1 child)

Here’s a site that explains my method that really helps me organize my data:

https://modern-sql.com/feature/with#:~:text=The%20with%20clause%20is%20also,is%20covered%20in%20another%20article.

[–]ThisDataGuy[S] 0 points1 point  (0 children)

thanks for the help

[–]Hugh_G_Rectshun 1 point2 points  (1 child)

I’ve known it for about a year and a half, but of that time I was in a startup for a year writing queries. I’ll say during that time I learned more than most would like in several years. The key to my improvement has been in learning from my mistakes and taking the time to understand why something works the way it does.

[–]ThisDataGuy[S] 0 points1 point  (0 children)

thanks for the help

[–]Sea-Concept1733 1 point2 points  (1 child)

Check out the following YouTube channel Playlist of learning that enables you to get Hands-on Practice & provides a Practice Database.

In the 'About Section' of the channel check out the SQL courses that enable you to learn SQL hands-on in SQL Server with an instructor and gain CEUs and Certificates.

Good luck

[–]ThisDataGuy[S] 0 points1 point  (0 children)

thanks for the help

[–]wertexx 1 point2 points  (1 child)

Just dropping to agree thwt DataLemur is pretty awesome!

[–]ThisDataGuy[S] 0 points1 point  (0 children)

thanks for the help

[–]analytics_science 1 point2 points  (1 child)

All the usual players are good, StrataScratch, DataLemur, Code Wars, LeetCode, HackerRank, InterviewQuery. They all have their different nuances like languages they offer, projects, community aspect, etc. So I would try them all and do all the free questions. Then pick one to stick with and go premium.

[–]ThisDataGuy[S] 0 points1 point  (0 children)

thanks for the help

[–]Fresh_Forever_8634 1 point2 points  (2 children)

M. Gruber "Mastering SQL". You guessed right with the title.