Skip to content

About

GPS fleet-tracking SQL Server database with daily/weekly/semi-monthly reporting queries and window-function analytics.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Fleet-Telemetry-SQL-Analytics

A GPS fleet-tracking SQL Server database and a set of analytical queries that turn raw telemetry into the same daily / weekly / semi-monthly reports used to monitor a real delivery/logistics fleet.

Part of a small GPS-analytics project series — see GPS-Telemetry-ETL-Pipeline for the Python side: cleaning noisy raw GPS pings before they ever reach a table like this one.

Why this project

Fleet monitoring systems log a GPS ping every few seconds — that's not a report, it's noise. This project models the layer that sits between the raw feed and a decision: a normalized schema, a synthetic-but-realistic dataset, and the SQL that turns trip and speed-event rows into the three report cadences an operations team actually reads.

Features

  • ✅ Normalized schema for vehicles, drivers, trips, geo-zones and speed events
  • ✅ Reproducible sample data generator (Python, fixed seed) — 10 vehicles, 8 drivers, ~200 trips over 45 days
  • ✅ Daily / weekly / semi-monthly report queries matching real fleet-ops reporting cycles
  • ✅ Window-function examples (RANK, LAG) for ranking vehicles and spotting speed anomalies
  • ✅ Two stored procedures so the reports can be scheduled instead of run by hand

Database structure

Table Purpose
Drivers Driver roster — name, license, hire date
Vehicles Fleet roster — plate, model, GPS device ID, status
GeoZones Operating areas with a posted speed limit (urban / highway / industrial)
Trips One row per completed trip — vehicle, driver, zone, shift, distance, idle time, peak speed
SpeedEvents A logged over-limit reading during a trip, with a computed OverLimitBy column
Drivers ──┐
          ├──< Trips >── GeoZones
Vehicles ─┘      │
                  └──< SpeedEvents

Getting started

  1. Clone the repository:
    git clone https://github.com/Dicapso/Fleet-Telemetry-SQL-Analytics.git
  2. Run schema.sql in SQL Server Management Studio (or sqlcmd) to create FleetTelemetryDB and its tables.
  3. Run seed_data.sql to load the sample dataset (already generated — no Python required).
  4. Run procedures.sql to create the stored procedures.
  5. Open analysis_queries.sql and run any of the four report sections.

Want a different dataset size or a different random seed? Edit the constants at the top of generate_data.py and re-run:

python generate_data.py

Example query

-- Highest recorded speed per zone, per ISO week (RANK)
WITH WeeklySpeed AS (
    SELECT gz.ZoneName, DATEPART(ISO_WEEK, t.StartTime) AS IsoWeek,
           v.PlateNumber, t.MaxSpeedKmh, gz.SpeedLimitKmh,
           RANK() OVER (PARTITION BY gz.ZoneID, DATEPART(ISO_WEEK, t.StartTime)
                         ORDER BY t.MaxSpeedKmh DESC) AS SpeedRank
    FROM dbo.Trips t
    JOIN dbo.GeoZones gz ON gz.ZoneID = t.ZoneID
    JOIN dbo.Vehicles v  ON v.VehicleID = t.VehicleID
)
SELECT * FROM WeeklySpeed WHERE SpeedRank = 1 ORDER BY IsoWeek, ZoneName;

Files

File Description
schema.sql Database and table definitions
generate_data.py Reproducible synthetic data generator
seed_data.sql Generated sample data, ready to run
analysis_queries.sql Daily / weekly / semi-monthly reports + window-function examples
procedures.sql Schedulable stored procedures for the daily and violation reports

Ideal for

  • Practicing T-SQL window functions on a realistic operational dataset
  • Prototyping fleet/logistics reporting before wiring up a BI tool
  • Anyone benchmarking a GPS-telemetry reporting pipeline

License

MIT — feel free to use, modify and share for learning or professional purposes.

Built by Dicapso

About

GPS fleet-tracking SQL Server database with daily/weekly/semi-monthly reporting queries and window-function analytics.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages