A comprehensive collection of SQL examples demonstrating various SQL concepts and operations using Microsoft SQL Server.
This repository contains a curated set of SQL examples that cover everything from basic queries to advanced database operations. It serves as both a learning resource and a quick reference guide for SQL developers working with Microsoft SQL Server, specifically using the AdventureWorksLT sample database.
The examples cover a wide range of SQL operations including:
- Basic Queries: Simple SELECT statements and column selection
- Filtering: WHERE clauses with various operators and conditions
- Aggregation: COUNT, MAX, MIN, AVG functions with GROUP BY
- Sorting: ORDER BY for result organization
- NULL Handling: Testing for NULL and NOT NULL values
- Result Limiting: Using TOP and PERCENT
- Pattern Matching: LIKE operator with wildcards
- Aliasing: Column and table aliases
- Joins: INNER, LEFT, RIGHT, and FULL OUTER joins
- Subqueries: Nested SELECT statements
- Set Operations: UNION for combining result sets
- Conditional Logic: CASE expressions
- Data Manipulation: INSERT, UPDATE, and DELETE operations
- Database Objects: Creating and managing databases, tables, indexes, and views
- Microsoft SQL Server (any recent version)
- AdventureWorksLT sample database
-
Install Microsoft SQL Server if you haven't already
-
Download and attach the AdventureWorksLT sample database:
# Download link https://learn.microsoft.com/en-us/sql/samples/adventureworks-install-configure
-
Connect to your SQL Server instance
-
Run the examples from the
examples.sql
file
This project is licensed under the MIT License - see the LICENSE file for details.