SQL-Examples Overview Welcome to the SQL-Examples repository! This repository showcases a variety of SQL scripts designed to demonstrate my knowledge of SQL in areas like data retrieval, data manipulation, creating views, stored procedures, functions, and more. The examples cover real-world scenarios such as managing invoices, vendors, boats, and trips.
Repository Structure This repository is organized by different use cases and SQL features:
Data Analysis Queries: Includes queries for summarizing, grouping, and analyzing data, such as invoice totals, payment dates, and vendor statistics. Stored Procedures & Functions: Demonstrates the creation of reusable stored procedures and functions for tasks like calculating balances and updating records. Views: Examples of using SQL views for easier access and querying of data across multiple tables. Error Handling: Includes examples of how to handle errors and ensure data integrity using triggers and constraints. Branching and Version Control: Demonstrates my use of Git and GitHub for version control with feature-specific branches.
Key Examples
-
Invoice and Vendor Analysis File: invoice_analysis.sql Description: Contains SQL queries that retrieve, aggregate, and analyze invoice and vendor data, including calculating total invoice amounts, identifying unpaid invoices, and grouping by payment dates.
-
Stored Procedure for Employee Updates File: employee_update_procedure.sql Description: Demonstrates the use of stored procedures with input parameters to update employee salaries, including error handling for negative values.
-
Views for Simplifying Data Access File: views.sql Description: Contains several SQL views that join related tables, providing a simple and efficient way to query data, such as open invoices and available trips.
-
Calculating Balance Due File: balance_due_function.sql Description: A SQL function to calculate the balance due on an invoice by subtracting payments and credits from the total invoice amount.