Learning SQL with Handwritten Notes ✍️



This content originally appeared on DEV Community and was authored by Mohit Decodes

SQL (Structured Query Language) is the standard language for dealing with relational databases. Whether you’re a backend developer, data analyst, or a tech enthusiast, SQL is an essential tool in your toolkit.

Today, I learned and created handwritten notes to help solidify the concepts. Here’s what I covered:

🔹 What is SQL?

SQL is used to read, manipulate, and store data in relational databases.

Why SQL?

  • Easy to learn & use
  • Powerful for querying large datasets
  • Preferred for data audits over spreadsheets

🧾 Basic SQL Syntax

SELECT Statement

SELECT * FROM Sales;

Selects all columns from the Sales table.

SELECT year, month FROM Sales;

Selects specific columns.

Aliases

SELECT west AS "West Region" FROM Sales;

Renames a column temporarily for readability.

🔍 Filtering with WHERE Clause

Basic Comparison

SELECT * FROM Sales WHERE Country = 'India';
SELECT * FROM Sales WHERE City != 'Delhi';
SELECT * FROM Sales WHERE SalesAmount > 50000;

🔢 LIMIT Clause

SELECT * FROM Sales LIMIT 100;

Limits output to 100 records.

➕ Arithmetic Operations

SQL supports row-wise arithmetic:

SELECT west + south AS total_sales FROM Sales;

📋 Data Modification

CREATE TABLE

CREATE TABLE Person (
  PersonID int,
  LastName varchar(255),
  FirstName varchar(255),
  Address varchar(255),
  City varchar(255)
);

INSERT INTO

INSERT INTO Person (FirstName, LastName) VALUES ('John', 'Doe');

UPDATE

UPDATE Sales SET City = 'Goa' WHERE CustomerID = 1;

DELETE

DELETE FROM Sales WHERE CustomerName = 'Bob';

🕳 NULL Handling

SELECT * FROM Sales WHERE Address IS NULL;
SELECT * FROM Sales WHERE Address IS NOT NULL;

📊 Aggregate Functions

  • COUNT()
  • SUM()
  • AVG()
  • MIN()
  • MAX()
SELECT COUNT(*) FROM Sales;
SELECT SUM(SalesAmount) FROM Sales;

📦 GROUP BY & HAVING

SELECT year, COUNT(*) FROM Sales GROUP BY year;
SELECT month, MAX(high) FROM Sales GROUP BY month HAVING MAX(high) > 400;

🧠 Logical Operators

  • AND, OR, NOT
  • LIKE, IN, BETWEEN
  • IS NULL, IS NOT NULL

Got stuck? Want to showcase your version? Drop a link or comment below.
📲 Follow me on Instagram or WhatsApp for daily frontend tips.


This content originally appeared on DEV Community and was authored by Mohit Decodes