All the course material is stored in the SQL Crash Course repository.
Hi everyone! Josep and Cornellius Yudha Wijaya from Non-Brand Data here 👋🏻
As promised, today we are publishing the next two issues of our SQL Crash Course – From Zero to Hero! 🚀
I am sure you are here to continue our SQL Crash Course Journey!📚
If this is your first time or you’ve forgotten what we’ll cover, we will examine seven key SQL topics, each divided into multiple posts across Non-Brand Data and DataBites.
📚 Previously in SQL Basics…
Remember last Thursday we already saw
📌 #3 Relational Data & Models by me in DataBites
📌 #4 Basic Commands by Cornellius Yudha Wijaya in Non-Brand Data.
Today, two fresh issues just dropped:
📌 #5 Filtering and Sorting (the one you're reading now) – where we focus on two essential commands: ORDER BY
and LIMIT
📌 #6 Aggregate Functions – in which Cornellius walks you through the most commonly used aggregates like SUM
, AVG
, and COUNT
With these, we wrap up Section 2: SQL Basics 🎉
Next week, we jump into Intermediate SQL with four exciting topics:
JOINS (INNER, LEFT, RIGHT, FULL)
UNION & UNION ALL
CASE Expressions
Functions (String, Date, Numeric)
So don’t miss out—let’s keep the SQL momentum going!
SQL Filtering & Sorting 🧹📊
Previously, we explored the SELECT, FROM, and WHERE commands — the building blocks of SQL.
Now, it’s time to take things up a notch.
Once you’ve filtered your data using WHERE, what if you want to sort the results? Or limit how many rows are returned?
That’s where ORDER BY and LIMIT come in.
These commands let you organize and control your query results. You’ll learn how to:
📌 ORDER BY to sort your data (ascending/descending).
📌 LIMIT to return only a specific number of rows.
Combine them for cleaner, faster results.
Let’s dive in.
✅ ORDER BY Command
The ORDER BY clause answers the question: “How should I sort the results?”
What It Does
Sorts the result set by one or more columns.
Defaults to ascending order (ASC), but you can use descending (DESC) too.
SELECT column1, column2
FROM table_name
ORDER BY column1 [ASC|DESC];
Let’s see various examples for the SELECT command:
👉 Sort Products by Price (Low to High)
SELECT product_name, price
FROM products
ORDER BY price ASC;
👉 Sort Products by Price (High to Low)
SELECT product_name, price
FROM products
ORDER BY price DESC;
👉 Sort by Multiple Columns
SELECT product_name, category, price
FROM products
ORDER BY category ASC, price DESC;
The Syntax for ORDER BY is always in the later part of our queries, as this command signifies that we want to order our final output in a specific way.
✅ LIMIT Command
The LIMIT clause answers: “How many results do I want to see?”
What It Does
Restricts the number of rows returned by your query.
Very useful when previewing data or working with large datasets. Its main advantages are two:
To control the number of data processed when running a quick query.
To set a maximum number of output records that the system can return.
The Syntax is present as follows:
SELECT column1
FROM table_name
LIMIT number;
Let’s see various examples for the SELECT command:
👉 Get the First 10 Products
SELECT product_name
FROM products
LIMIT 10;
👉 Top 5 Most Expensive Products
SELECT product_name, price
FROM products
ORDER BY price DESC
LIMIT 5;
👉 Combine WHERE, ORDER BY, and LIMIT
SELECT product_name, price
FROM products
WHERE category = 'Electronics'
ORDER BY price DESC
LIMIT 3;
The LIMIT clause always goes in the end as it limits the number of records that the output can return.
And now? It is your turn to play in our SQL playground with these two clauses.
👉🏻 SQL playground with ORDER BY and LIMIT
And there you have it — your toolkit to filter, sort, and focus your queries.
These two commands might look simple, but they make your SQL results way more useful.
Stay tuned as we move deeper into SQL! 👩💻👨💻
How to Get Started 🚀
Over the coming weeks, we’ll guide you through:
✅ SQL Fundamentals
✅ Intermediate SQL
✅ Advanced SQL
✅ Database Operations
✅ Writing Efficient Queries
Once you grasp the basics, practice is key! Start working on real-world projects and solving hands-on data problems.
What’s Next? ➡️
This is the first of many posts about the upcoming SQL Courses. It will only explain what SQL is in its crude form.
To get the full experience and fully immersed in the learning:
👉 Subscribe to Databites.tech (By Josep)
👉 Subscribe to Non-Brand Data (By Cornellius)
👉 Check out the SQL Crash Course GitHub repo
👉 Share with your friend and whoever needs it!
🗓️ Every Thursday, you will have two new issues in your inbox!
Let’s dive in and make SQL less scary, more fun, and way more useful! 🚀
Josep & Cornellius