
Understanding SQL Joins and Window Functions
If you've ever stared at a SQL query and wondered what PARTITION BY actually does, this article is for you. I'm going to break down two of the most important SQL concepts Joins and Window Functions PART 1: SQL JOINS What is a Join? A Join is how you combine data from two or more tables. Think of it like connecting two spreadsheets using a shared column like a customer ID that appears in both a Customers table and an Orders table. The Tables We'll Use Customers: id name 1 Alice 2 Bob 3 Carol Orders: id customer_id amount 1 1 500 2 1 300 3 2 200 Notice that Carol (id = 3) has no orders, and all orders belong to either Alice or Bob. Keep that in mind. it's going to matter a lot when we look at how different JOINs behave. Understanding Left and Right Tables Before we look at any specific JOIN type, there's one concept you need to lock in first. Every JOIN has a Left table and a Right table, and the difference matters. The table written after FROM is the Left table The table written after J
Continue reading on Dev.to Beginners
Opens in a new tab



