SQL Cheat Sheet: Full Guide for Beginners & Professionals

Every core SQL command you need, organized in one quick-reference guide.

Whether you're writing your first query or optimizing reports at work, having a reliable SQL cheat sheet saves time. This guide condenses the commands used daily by data analysts into one place.

Basic Query Structure

SELECT column1, column2
FROM table_name
WHERE condition
ORDER BY column1 ASC;

Filtering and Sorting

  • WHERE — filter rows based on a condition
  • ORDER BY — sort results ascending or descending
  • LIMIT / TOP — restrict the number of rows returned

Joining Tables

SELECT a.name, b.order_date
FROM customers a
INNER JOIN orders b ON a.id = b.customer_id;

Use INNER JOIN for matching rows only, LEFT JOIN to keep all rows from the left table, and FULL OUTER JOIN when you need everything from both sides.

Aggregation

SELECT department, COUNT(*) AS total_employees
FROM employees
GROUP BY department
HAVING COUNT(*) > 5;
💡 Tip: Remember the logical order SQL actually evaluates in: FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY.

Useful Functions

  • COUNT(), SUM(), AVG(), MIN(), MAX()
  • DISTINCT to remove duplicate rows
  • CASE WHEN for conditional logic inside a query

Bookmark this guide as your quick reference while you practice — the more queries you write, the more naturally these patterns will come.

Ready to go beyond the basics?

Get hands-on training, live mentorship, and placement support with Uncodemy's Data Analytics Course.

Explore Data Analytics Course →