Author: Le Dang Trung Duc
Lecturer: Le Nhat Tung, MSc
This repository contains a structured collection of SQL scripts developed during my deep-dive practice with Microsoft SQL Server. The project utilizes the classic Microsoft Northwind sample database to simulate real-world data extraction, manipulation, and analytical tasks[cite: 5].
The primary goal of this repository is to demonstrate a robust understanding of relational database management, ranging from simple data retrieval to complex analytical functions and database administration commands.
Based on the scripts in this repository, the following SQL proficiencies are showcased:
- Basic CRUD & Selection: Executing
SELECT, handlingDISTINCTvalues, and limiting results withTOP[cite: 5]. - Advanced Filtering: Utilizing
WHEREclauses with complex boolean logic (AND,OR,NOT),BETWEEN, andIN/NOT INoperators[cite: 5]. - Pattern Matching: Applying
LIKEoperators with wildcards (%,_,[],[^]) for precise string extraction[cite: 5].
- Aggregate Functions: Calculating summary statistics using
MIN(),MAX(),SUM(),AVG(), andCOUNT()[cite: 5]. - Grouping Logic: Organizing data with
GROUP BYand applying post-aggregation filters using theHAVINGclause[cite: 5]. - Date/Time Functions: Extracting specific timeframes using
YEAR(),MONTH(), andDAY()[cite: 5].
- Table Joins: Merging datasets across multiple relational tables using
INNER JOIN,LEFT JOIN,RIGHT JOIN, andFULL OUTER JOIN[cite: 5]. - Set Operations: Combining result sets from multiple queries using
UNIONandUNION ALL[cite: 5].
- Subqueries: Writing nested queries within
SELECT,FROM, andWHEREclauses to dynamically filter and calculate data (e.g., finding customers with record-breaking revenues)[cite: 6]. - Common Table Expressions (CTEs): Simplifying complex aggregations and multi-step calculations using the
WITHclause[cite: 6]. - Recursive CTEs: Handling hierarchical data structures, demonstrated through tasks like building employee management trees (ReportsTo) and generating mathematical sequences (Fibonacci, Factorials)[cite: 6].
- Window Functions: Performing advanced analytics without collapsing rows using
RANK(),DENSE_RANK(), andLAG()paired withPARTITION BYandORDER BYclauses to calculate year-over-year rankings and track previous order dates[cite: 6].
- Database & Table Creation: Using
CREATE DATABASEandCREATE TABLEto set up new schemas. - Schema Modification: Applying
ALTER TABLEto add columns and enforce rules viaCHECKconstraints[cite: 7]. - Data Modification: Inserting single and multiple records with
INSERT INTO, duplicating table structures withSELECT INTO, updating existing records withUPDATE, and safely removing data withDELETE[cite: 7].
- RDBMS: Microsoft SQL Server.
- IDE: SQL Server Management Studio (SSMS)
/SQL LEARNING/: Contains all.sqlquery files categorized logically by topic.README.md: Project documentation.
(Note: The actual Northwind database files .mdf/.ldf are not included in this repository. To run these scripts, you can download and restore the standard Northwind database directly from Microsoft's official documentation).