
SQL Joins and Window Functions- What I Learned Catching Up After Missing Class..
Introduction SQL Joins and Window Functions are essential tools for any data professional. Joins help combine data from multiple tables, while Window Functions allow calculations across rows without collapsing them. This guide breaks down both concepts with simple examples using African names and cities. Part 1: SQL Joins Sample Tables First, let's create our sample data: sql -- Departments table CREATE TABLE departments ( dept_id INT PRIMARY KEY, dept_name VARCHAR(50), location VARCHAR(50) ); INSERT INTO departments VALUES (1, 'Engineering', 'Nairobi, Kenya'), (2, 'Marketing', 'Cape Town, South Africa'), (3, 'Sales', 'Lagos, Nigeria'), (4, 'Legal', 'Nairobi, Kenya'), (5, 'HR', 'Kampala, Uganda'); -- Employees table CREATE TABLE employees ( emp_id INT PRIMARY KEY, emp_name VARCHAR(50), dept_id INT, salary DECIMAL(10,2) ); INSERT INTO employees VALUES (1, 'Nginda Nganga', 1, 85000), (2, 'Kwame Mensah', 1, 75000), (3, 'Zanele Khumalo', 2, 65000), (4, 'Akinyi Odera', NULL, 55000), (5, 'Ka
Continue reading on Dev.to Beginners
Opens in a new tab


