Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQL Proficiency πŸš€

Welcome to the SQL Proficiency Document! This document serves to illustrate proficiency in the SQL coding lanuage.. Let's dive in! πŸ’»

Table of Contents πŸ“‘

  1. Introduction
  2. Basic Queries
  3. Advanced Queries
  4. Data Manipulation
  5. Joins & Unions
  6. Aggregation
  7. Window Functions
  8. Indexes and Optimization
  9. Transactions
  10. Stored Procedures
  11. Data Modeling
  12. Bonus Tips
  13. Resources

Introduction 🌐

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!

Basic Queries πŸ•΅οΈβ€β™‚οΈ

Selecting Columns

SELECT column1, column2
FROM table
WHERE condition;

Filtering Results

SELECT *
FROM table
WHERE column = 'value';

Advanced Queries πŸš€

Subqueries

SELECT *
FROM table
WHERE column IN (SELECT column FROM another_table);

Common Table Expressions

WITH cte_name AS (
  SELECT column
  FROM table
)
SELECT *
FROM cte_name;

Data Manipulation ✨

Inserting Data

INSERT INTO table (column1, column2)
VALUES ('value1', 'value2');

Updating Data

UPDATE table
SET column = 'new_value'
WHERE condition;

Joins and Unions πŸ”—

Inner join

SELECT *
FROM table1
JOIN table2 ON table1.column = table2.column;

Union

SELECT column FROM table1
UNION
SELECT column FROM table2;

Aggregation πŸ“Š

Group By

SELECT column, COUNT(*)
FROM table
GROUP BY column;

Having clause

SELECT column, COUNT(*)
FROM table
GROUP BY column
HAVING COUNT(*) > 1;

Window Functions πŸͺŸ

Rank and Partition (could also be Row_Number)

SELECT column, RANK() OVER (PARTITION BY category ORDER BY value DESC) AS ranking
FROM table;

Indexes and Optimization βš™οΈ

Indexing

CREATE INDEX index_name
ON table (column);

Query Optimization

EXPLAIN SELECT column
FROM table
WHERE condition;

Transactions πŸ”„

BEGIN TRANSACTION;

-- SQL Statements here

COMMIT;

Stored Procedures πŸ“¦

CREATE PROCEDURE procedure_name
AS
BEGIN
  -- SQL Statements here
END;

Data Modeling πŸ› οΈ

Alt text

Bonus Tips

  1. Use aliases for readability: SELECT column AS alias_name.
  2. Learn to love and hate indexesβ€”they can make or break performance.
  3. Embrace the power of window functions for complex analyses.

About

Illustration of coding of SQL

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors