📊 PostgreSQL – Aggregating and Grouping
So far in this course, every query we’ve written has done one simple thing: 👉 It fetched rows exactly as they exist in the database. For example: SELECT FROM users;
Muhammad Sufiyan · 5d ago



So far in SQL, we’ve learned these keywords: FROM JOIN WHERE GROUP BY Now we’re introducing a new keyword: 🔥 HAVING At first, HAVING looks very similar to WHERE. B
Read the storySo far in this course, every query we’ve written has done one simple thing: 👉 It fetched rows exactly as they exist in the database. For example: SELECT FROM users;
Muhammad Sufiyan · 5d agoThis is one of those topics that you will probably come back to again and again in the future. Joins are powerful — but they can also be confusing at first. So in this lesson, we
Muhammad Sufiyan · 5d agoIn the last lesson, I mentioned two things in a very mysterious way: 1. Sometimes the ordering of FROM and JOIN matters. 2. There are different kinds of joins available in SQL
Muhammad Sufiyan · 5d agoWe’ve now written several JOIN queries. Before moving forward, there are some very important things you need to understand about JOIN syntax. These small details will save you fr
Muhammad Sufiyan · 5d agoNow we are entering one of the most important concepts in SQL: JOIN This is where SQL starts to feel like real backend development. The Problem We Want to Solve We wan
Muhammad Sufiyan · 5d agoUp until now, we’ve been working with simple tables and writing basic queries. But in real-world applications, data is almost always connected across multiple tables. In this sec
Muhammad Sufiyan · 5d agoIn the previous lesson, we tested: 🔥 ON DELETE CASCADE When we deleted a user, all their related photos were automatically deleted. Now we’re going to explore a very differ
Muhammad Sufiyan · 5d agoSo far, we’ve learned: - What primary keys are - What foreign keys are - How insertion behaves when foreign keys are involved Now it’s time to look at the opposite oper
Muhammad Sufiyan · 5d agoUnderstanding Data Consistency in PostgreSQL Up until now, we’ve learned: - What primary keys are - What foreign keys are - How they help us create relationships betwe
Muhammad Sufiyan · 5d agoNow that we’ve created our users and photos tables and connected them using a foreign key, it’s time to actually use that relationship. Enough theory — let’s write s
Muhammad Sufiyan · 5d agoNow that we have created our users table, it’s time to move one step forward and build a photos table. This table is very important because this is where we will introdu
Muhammad Sufiyan · 5d agoEnough theory for now. Let’s get our hands dirty and actually write some SQL. Up till now, we’ve talked a lot about relationships, primary keys, and foreign keys. But none of
Muhammad Sufiyan · 5d agoSo far, we’ve learned about Primary Keys and Foreign Keys. Now it’s time to understand how these two things actually help us build relationships inside a real database
Muhammad Sufiyan · 5d agoHow Databases Actually Store Relationships Up until now, we’ve talked a lot about relationships in databases: - One-to-Many - Many-to-One - One-to-One - Many-to-Many But
Muhammad Sufiyan · Aug 2So far, we’ve already discussed one-to-many and many-to-one relationships, which are the most common relationships you’ll use in real applications. In this lesson, we’re g
Muhammad Sufiyan · Aug 2When we started learning SQL, we mostly worked with single tables. But in real-world applications, data is never isolated — tables are connected to each other. In our pho
Muhammad Sufiyan · Aug 2Up until now, we’ve spent a good amount of time writing basic SQL. But if we’re being honest, the SQL we’ve written so far doesn’t really reflect how things work in the real
Muhammad Sufiyan · Aug 2So far, we’ve learned how to: - insert data - read data - update data Now let’s take a look at deleting data from a table. Deleting rows in PostgreSQL is actually very simpl
Muhammad Sufiyan · Aug 2Now that we have a solid understanding of the WHERE keyword, it’s time to look at two very important operations that we frequently perform on database tables: - Updating r
Muhammad Sufiyan · Aug 2Let’s do a quick practice exercise to make sure the idea of WHERE is crystal clear. Once again, we are working with a table called phones. Each row in this table represen
Muhammad Sufiyan · Aug 2So far, we’ve learned how to filter rows using very simple comparisons like: - = (equal) - != (not equal) - (greater than) - < (less than) But SQL gives us more power
Muhammad Sufiyan · Aug 2Real-time applications are everywhere. When someone sends you a message on WhatsApp, you do not refresh the page to receive it. When a driver changes location on a ride-hailing
Muhammad Sufiyan · Jul 26We’ve already seen that the WHERE keyword allows us to filter rows returned by a query. In simple words: WHERE checks each row one by one and decides whether it should
Muhammad Sufiyan · Jul 26Up to this point, every query we’ve written has returned all rows from a table. But in real applications, we usually don’t want everything. Most of the time, we want to f
Muhammad Sufiyan · Jul 26Just like we can use operators to work with numbers, SQL also provides operators and functions to work with strings. Using these, we can: - join strings together - change tex
Muhammad Sufiyan · Jul 26So far, we’ve learned how to create calculated columns using SQL. Now it’s time to practice and make sure this concept is completely clear. In this task, you’ll apply wha
Muhammad Sufiyan · Jul 26So far, we’ve learned how to retrieve data from a table using SELECT. At this point, it might look like SQL can only return the exact data that is already stored in the
Muhammad Sufiyan · Jul 26At this point, we have successfully stored data inside the cities table. Now the next step is to retrieve that data from the database. To do this, PostgreSQL provides the
Muhammad Sufiyan · Jul 26Now that our cities table is ready, the next step is to add data into it. We want to store information about these cities: - Tokyo - Delhi - Shanghai - Sao Paulo Along wit
Muhammad Sufiyan · Jul 26So far in SQL, we’ve learned these keywords: FROM JOIN WHERE GROUP BY Now we’re introducing a new keyword: 🔥 HAVING At first, HAVING looks very similar to WHERE. B
Muhammad Sufiyan · 5d agoOne thoughtful digest from Backend Engineering Hub, delivered when there is something worth reading.