SQL Cheatsheet: The Complete Guide for Data-Driven Careers (2025 Edition)
Structured Query Language (SQL) is a programming language used to manage and interact with data stored in relational databases. It allows users to store, retrieve, modify, and delete data efficiently.
Think of SQL as the grammar of data. Just like we use grammar to write meaningful sentences, SQL helps us write commands to interact with data.
Imagine your phone’s contact list: it stores names, numbers, and birthdays. Now imagine being able to quickly find all friends born in July or update a friend’s number with a single command. That’s what SQL lets you do—but with any kind of data, at scale.
Whether you're managing large datasets, building dashboards, or analyzing customer behavior, SQL is a foundational skill for every data professional. This cheatsheet is your quick-access guide—clear, complete, and career-focused.
📥 Download the Free SQL Cheat Sheet
Let’s Start with a Simple Analogy
Think of a database like a digital notebook where we store and organize information.
Now imagine you’re managing a class of students:
- You add a new student’s name and age → that’s INSERT
- You look up who’s already enrolled → that’s SELECT
- You update a student’s age when they have a birthday → that’s UPDATE
- You remove a student who transferred → that’s DELETE
These four actions are the building blocks of SQL. Together, they’re called CRUD operations — short for Create, Read, Update, and Delete.
Let’s dive into each one with simple examples.👇
CRUD Operations (The Foundation of SQL)
CRUD stands for Create, Read, Update, Delete—the four essential operations used in all databases.
Create – INSERT: Add new data into a table.
INSERT INTO students (name, age) VALUES ('Ravi', 21);
Read – SELECT: Retrieve existing data.
SELECT * FROM students;
Update – UPDATE: Modify current values.
UPDATE students SET age = 22 WHERE name = 'Ravi';
🧠 Tip: Always use WHERE in UPDATE and DELETE to avoid unintentional full-table modifications.
📌 Real-World Use Cases
E-Commerce Example
SELECT p.category, SUM(p.price) AS revenue
FROM products p
JOIN orders o ON p.id = o.product_id
GROUP BY p.category;
HR Management
SELECT d.name AS department, COUNT(e.id) AS employee_count
FROM departments d
LEFT JOIN employees e ON d.id = e.department_id
GROUP BY d.name;
Mini Quiz (Test Your SQL Knowledge!)
🔹What is the difference between INNER JOIN and LEFT JOIN?
- INNER JOIN returns only matching rows from both tables.
- LEFT JOIN returns all rows from the left table and matching rows from the right.
🔹Write a query to get the third-highest salary.
SQL query
SELECT DISTINCT salary FROM employees ORDER BY salary DESC LIMIT 1 OFFSET 2;
🔹 What’s the difference between WHERE and HAVING?
- WHERE filters rows before grouping.
- HAVING filters after aggregation (used with GROUP BY).
🔹 How do you find duplicate entries in a table?
SQL query
SELECT column_name, COUNT(*) FROM table_name GROUP BY column_name HAVING COUNT(*) > 1;
🔹What does LIMIT 1 OFFSET 2 mean?
Skips the first 2 rows and returns the 3rd row.Handy Shortcuts & Cheat Prompts
- CTRL + ENTER — Run SQL query
- DESC table_name; — View table schema
- Prompt: "Write a query to find inactive users older than 30"
Master SQL. Build dashboards. Land high-growth roles.
🚀 Join OdinSchool’s Data Science Bootcamp to learn:
SQL, Python, Data Visualization
Machine Learning, Real Projects
Resume & Interview Support
👉 Explore OdinSchool’s Data Science Course