Welcome to the SQL Proficiency Document! This document serves to illustrate proficiency in the SQL coding lanuage.. Let's dive in! 💻
- Introduction
- Basic Queries
- Advanced Queries
- Data Manipulation
- Joins & Unions
- Aggregation
- Window Functions
- Indexes and Optimization
- Transactions
- Stored Procedures
- Data Modeling
- Bonus Tips
- Resources
SQL (Structured Query Language) is the language of databases. Whether you're fetching data or transforming it, SQL is your go-to tool. Let's explore its depths!
SELECT column1, column2
FROM table
WHERE condition;
SELECT *
FROM table
WHERE column = 'value';
SELECT *
FROM table
WHERE column IN (SELECT column FROM another_table);
WITH cte_name AS (
SELECT column
FROM table
)
SELECT *
FROM cte_name;
INSERT INTO table (column1, column2)
VALUES ('value1', 'value2');
UPDATE table
SET column = 'new_value'
WHERE condition;
SELECT *
FROM table1
JOIN table2 ON table1.column = table2.column;
SELECT column FROM table1
UNION
SELECT column FROM table2;
SELECT column, COUNT(*)
FROM table
GROUP BY column;
SELECT column, COUNT(*)
FROM table
GROUP BY column
HAVING COUNT(*) > 1;
SELECT column, RANK() OVER (PARTITION BY category ORDER BY value DESC) AS ranking
FROM table;
CREATE INDEX index_name
ON table (column);
EXPLAIN SELECT column
FROM table
WHERE condition;
BEGIN TRANSACTION;
-- SQL Statements here
COMMIT;
CREATE PROCEDURE procedure_name
AS
BEGIN
-- SQL Statements here
END;
- Use aliases for readability: SELECT column AS alias_name.
- Learn to love and hate indexes—they can make or break performance.
- Embrace the power of window functions for complex analyses.