Interactive SQL Environment for Learning & Testing
Connected
π Query History
β±οΈ 0msπ 0 rows
Execute a query to see results...
π Query Execution Plan
π SQL Tutorial
π SQL Basics
Learn the fundamentals of SQL queries:
SELECT: Retrieve data from tables
WHERE: Filter rows based on conditions
ORDER BY: Sort results
LIMIT: Limit number of results
SELECT name, email FROM customers WHERE country = 'USA' ORDER BY name LIMIT 10;
π SQL Joins
Combine data from multiple tables:
INNER JOIN: Matching records from both tables
LEFT JOIN: All records from left table
RIGHT JOIN: All records from right table
FULL JOIN: All records from both tables
SELECT c.name, o.total FROM customers c INNER JOIN orders o ON c.id = o.customer_id;
β‘ SQL Functions
Use built-in functions for data manipulation:
COUNT, SUM, AVG: Aggregate functions
UPPER, LOWER: String functions
DATE functions: Date manipulation
CASE WHEN: Conditional logic
SELECT COUNT(*) as total_customers, AVG(age) as avg_age FROM customers;
π Advanced SQL
Complex queries and optimizations:
Subqueries: Nested SELECT statements
Window Functions: ROW_NUMBER, RANK, etc.
CTEs: Common Table Expressions
Indexes: Performance optimization
WITH top_customers AS (SELECT customer_id, SUM(total) as spent FROM orders GROUP BY customer_id) SELECT * FROM top_customers ORDER BY spent DESC LIMIT 5;