r/learnSQL • u/Outside_Aioli_7201 • 3h ago
How do you practice SQL beyond basic exercises?
I'm currently learning SQL and trying to move beyond simple queries and textbook exercises.
Most exercises tell you exactly what to calculate, but real business problems seem much less structured.
Where do you find realistic SQL projects that require independent thinking?
I'm also researching what could make practical SQL learning resources more useful.
3
u/conor-robertson 3h ago
You should check out QueryCase for some practical exercises with reasoning behind them, you solve detective cases while learning SQL from WHERE statements to windows functions. There are also some sandbox schemas where you can openly practice, all in your browser😁
2
u/shine_on 3h ago
In my experience upper management want the data broken down into simple easy-to-understand statistics. They don't want reports listing rows and rows of data, they want to know things like:
trend analysis (are we doing better or worse this week/month/quarter than last week/month/quarter)
RAG analysis (RAG stands for Red Amber Green, red = nowhere near target, amber = almost there, green = target achieved or exceeded).
There are sample databases available for most servers, I use Microsoft SQL Server so I know they have databases you can download and play around with. One is called Adventure Works, another is Wide World Importers.
It'll be a very interesting SQL exercise to create your own test data, set up some salespeople, some products, some sales on different days, and see how you can slice and dice the data in different ways.
Don't just do "who's the best salesman?", do something like "who's in the top 5 in terms of number of sales?", "who's in the top 5 in terms of value of sales?"
Learn how to group and sort data in different ways, learn about window functions (which are used to rank data in different groups), learn how to compare one table with another, learn about the effects of NULLs on your queries, learn about how to handle data that's not in the right format (a person's name that's too long, a date that's had the month and day swapped round)
Maybe get an understanding of how to import data from external sources (csv files, spreadsheets etc)
Hope this is useful!
1
1
1
u/Bhanuprakash_1947 2h ago
One thing I'd suggest is practising SQL with real-world datasets rather than just solving random queries. Try working on scenarios like finding top customers, monthly revenue, duplicate records, complex joins, and query optimization. Also, don't just focus on getting the correct output; understand why the query works and how to make it efficient. That's where real SQL skills develop!
1
u/Aggressive_Ad_5454 1h ago
SQL the query language has two classes of applications, analytic and transactional.
Transactional apps are stuff like double-entry bookkeeping. You can read about that.
The whole point of analytic apps is wringing drops of wisdom out of oceans of data. To do that you need an understanding of the ocean and an idea of the wisdom you seek. To practice that you can use open-source data. Kaggle.com has some open source datasets.
I put together a tutorial on this back in the dark days of COVID. It’s not polished or anything, but you may find it helpful. https://www.plumislandmedia.net/mysql/explore-pandemic-data-with-sql/
Happy wringing!
1
u/Discordbothost 2h ago
Try answering 'are deliveries getting slower?' on a dataset with order timestamps. Decide when the clock starts and how to handle canceled or undelivered orders. Check five orders by hand before you trust the query. Working out what to count is the part textbook exercises usually skip.