Skip to content

baerdatadev/sql-script-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

SQL Script Examples

This repository contains a curated set of SQL scripts taken from real production systems. The goal is to demonstrate practical, operational SQL patterns rather than isolated examples or academic exercises.

The scripts have been sanitized to remove proprietary identifiers while preserving structure, logic, and design decisions.


Repository Structure

/analytics
/operational
  • analytics: Data warehouse, ELT, and reporting-oriented SQL patterns
  • operational: System-level views, functions, and decision-support logic used by applications

Analytics Scripts

These scripts focus on transforming raw or transactional data into structures suitable for reporting, analysis, and performance measurement.

  • Average Inventory View
    Calculates average inventory levels between snapshots using a standard financial method.

  • Concurrent Usage / Interval Analysis
    Buckets activity into fixed time intervals to analyze concurrent usage over time.

  • Date & Time Dimensions
    Builds reusable calendar and time dimensions for dimensional modeling.

  • Item Load & Pareto Processing
    Loads item data and recalculates classifications used for reporting and prioritization.

  • Activity / History Log Processing
    Transforms event logs into structured activity-time metrics for analytics.


Operational Scripts

These scripts support live operations, application behavior, and decision-making logic.

  • Order Pickability Query
    Determines whether orders are fully pickable using running totals and zone grouping.

  • Inventory Availability Views
    Combines multiple inventory states into a single consumable view.

  • Replenishment Logic Functions
    Calculates when and where inventory replenishment is required based on configurable rules.

  • Order Summary Views
    Aggregates line-level order details into order-level operational summaries.

  • Publication / Slotting Logic
    Groups and slots records into fixed output templates based on business constraints.


Design Notes

Across all scripts, the following principles are emphasized:

  • Defensive SQL design for imperfect or evolving data
  • Reusable views and functions instead of one-off queries
  • Performance-aware use of window functions and aggregation
  • Business-rule-driven modeling rather than purely technical schemas

These scripts are intended as reference implementations and are not expected to run as-is without supporting schema and data.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published