TGViewer
Data Analytics & AI | SQL Interviews | Power BI Resources Data Analytics & AI | SQL Interviews | Power BI Resources @data_visual · 27.5K subscribers
Post #810 1.37K
SQL Cheatsheet 📝

This SQL cheatsheet is designed to be your quick reference guide for SQL programming. Whether you’re a beginner learning how to query databases or an experienced developer looking for a handy resource, this cheatsheet covers essential SQL topics.

1. Database Basics
- CREATE DATABASE db_name;
- USE db_name;

2. Tables
- Create Table: CREATE TABLE table_name (col1 datatype, col2 datatype);
- Drop Table: DROP TABLE table_name;
- Alter Table: ALTER TABLE table_name ADD column_name datatype;

3. Insert Data
- INSERT INTO table_name (col1, col2) VALUES (val1, val2);

4. Select Queries
- Basic Select: SELECT * FROM table_name;
- Select Specific Columns: SELECT col1, col2 FROM table_name;
- Select with Condition: SELECT * FROM table_name WHERE condition;

5. Update Data
- UPDATE table_name SET col1 = value1 WHERE condition;

6. Delete Data
- DELETE FROM table_name WHERE condition;

7. Joins
- Inner Join: SELECT * FROM table1 INNER JOIN table2 ON table1.col = table2.col;
- Left Join: SELECT * FROM table1 LEFT JOIN table2 ON table1.col = table2.col;
- Right Join: SELECT * FROM table1 RIGHT JOIN table2 ON table1.col = table2.col;

8. Aggregations
- Count: SELECT COUNT(*) FROM table_name;
- Sum: SELECT SUM(col) FROM table_name;
- Group By: SELECT col, COUNT(*) FROM table_name GROUP BY col;

9. Sorting & Limiting
- Order By: SELECT * FROM table_name ORDER BY col ASC|DESC;
- Limit Results: SELECT * FROM table_name LIMIT n;

10. Indexes
- Create Index: CREATE INDEX idx_name ON table_name (col);
- Drop Index: DROP INDEX idx_name;

11. Subqueries
- SELECT * FROM table_name WHERE col IN (SELECT col FROM other_table);

12. Views
- Create View: CREATE VIEW view_name AS SELECT * FROM table_name;
- Drop View: DROP VIEW view_name;
  • ❤ 10
  • 👍 1
More from @data_visual
  1. Oct 2, 2026Data Analyst Roadmap
  2. Sep 28, 2026🎯 GigaChat 3.5 Reasoning: 5 Key Features 1️⃣ Advanced Reasoning: Explores multiple step-b…
  3. Sep 23, 2026🚀 The 10 Levels of AI Agents — Where We Stand Today AI isn’t a single goal — it’s an evol…
  4. Sep 14, 2026AI tools to increase your productivity in 2026 👇 1/ Granola: AI meeting notes that captur…
  5. Sep 6, 2026Data Analyst interviews will be easier if you learn these tools in sequence: ➤ 𝗗𝗮𝘁𝗮 𝗙…
  6. Aug 29, 2026SQL Joins — A Practical Cheatsheet for Professionals If you’re working with relational dat…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →