Brian Cohen | Database Engineer & T-SQL Specialist
Portfolio of Brian Cohen — Database Engineer specializing in HealthTech data auditing, custom SQL architecture, and T-SQL batch development.
About Brian Cohen
Healthcare data engineer, educator, and author based in Portland, Oregon. With deep expertise across SQL Server, T-SQL, Python, and data auditing, Brian builds mission-critical data pipelines and high-throughput transactional architectures.
Core specialties include: Transact-SQL (T-SQL), Microsoft SQL Server, Query Optimization, Database Architecture, Performance Tuning, Indexing Strategies, SSIS/ETL Processing, Data Modeling, DAX, Power BI, and Relational Database Design.
Author of Real SQL Queries: 50 Challenges (Anniversary Edition)
ISBN: 979-8991917803 | 186 Pages | Published December 2024
A comprehensive challenge workbook featuring 50 realistic, business-grounded T-SQL problems built on Microsoft's AdventureWorks2022 sample database. Covers subqueries, window functions, common table expressions (CTEs), conditional logic, and set operations.
Buy Real SQL Queries on Amazon (Paperback & Kindle eBook)
Real SQL Queries Challenge Directory
Level 1: Foundation (Challenges 01–10)
- Challenge 01: Needy Accountant — Multi-table Aggregations (Country maximum sales tax rates via tax and geographic reference joins)
- Challenge 02: Illustrations Needed — Anti-Joins & Missing Data (Finding product models with no illustrations using LEFT JOIN / IS NULL and NOT EXISTS)
- Challenge 03: Who Left That Review? — LEFT JOIN & NULL Analysis (Connecting product reviewers to business entities by email)
- Challenge 04: Hire Dates for NDA — Boolean & Date Filtering (Identifying current employees hired outside date thresholds)
- Challenge 05: Products in Yellow? — Basic Filtering (Filtering finished goods for specific product colors)
- Challenge 06: Products and Their Subcategories — Relational Joins (Combining products with subcategories for finished goods catalogs)
- Challenge 07: Total Sales by Territory — Grouped Aggregations (Summarizing sales and taxes by geographic territory with SUM and GROUP BY)
- Challenge 08: Email Marketing Campaign — Multi-table Joins (Assembling customer names and email addresses across relationships)
- Challenge 09: Special Offers — Anti-Joins & Missing Relationships (Active discounted special offers unassigned to products)
- Challenge 10: Work Orders — Grouped Counts (Historical work orders counted by product and sorted by frequency)
Level 2: Intermediate (Challenges 11–32)
- Challenge 11: The Translators — Multi-table Joins (Product descriptions in languages other than English)
- Challenge 12: The 2/22 Promotion — Scenario Modeling & Aggregation (Modeling hypothetical freight promotion gains and losses)
- Challenge 13: Vendor Credit Ratings — CASE Expressions & Aggregation (Coded vendor statuses translated into readable labels with average credit ratings)
- Challenge 14: Transaction History — UNION & Min/Max Aggregation (Comparing current and archived transaction tables)
- Challenge 15: Holiday Bonus — Latest-Row Retrieval (Calculating employee holiday bonuses from current pay rates)
- Challenge 16: Commission Percentages — Window Function Ranking (Ranking salespeople by commission percentage and bonus)
- Challenge 17: Domain and UserName Separation — String Parsing (Splitting login IDs into domain and username)
- Challenge 18: Loyal Customers — HAVING & Distinct Counts (Identifying customer loyalty thresholds based on order activity)
- Challenge 19: Revenue Ranges — CASE Bucketing (Classifying sales orders into revenue categories)
- Challenge 20: Upsell Tuesdays — Date-Based Aggregation (Revenue and order counts compared across days of the week)
- Challenge 21: Vacation Hours — Maximum-Value Retrieval (Finding employees tied for greatest vacation hours)
- Challenge 22: Two Free Bikes — Random Row Selection (Random employee selection for giveaways)
- Challenge 23: Excess Inventory — Correlated Counts & Aggregation (Excess inventory discounts and sales order frequencies)
- Challenge 24: Months Since Last Order — Latest-Date Analysis (Calculating months passed since store's most recent order)
- Challenge 25: Toronto — Multi-table Location Joins (Store and address relationships for Main Office locations)
- Challenge 26: Print Catalog — Aggregate Filtering (Product attributes combined with summarized inventory quantities)
- Challenge 27: Label Mix-Up — Complex Multi-table Filtering (Tracing online orders through product, customer, and contact tables)
- Challenge 28: Phone Number Types — Percent-of-Total Analysis (Phone number distribution and percentage breakdown)
- Challenge 29: Revenue by State — Geographic Aggregations (Shipping address joins summarizing revenue by US state)
- Challenge 30: Scrap Rate — TOP PERCENT & Calculated Ratios (Highest 10% scrap rate work orders above 3%)
- Challenge 31: Shift Coverage — Workforce Aggregations (Production employees counted across shifts)
- Challenge 32: The Classic Vest — Pattern Matching & Grouped Sums (Purchasing data summaries for Classic Vests)
Level 3: Advanced (Challenges 33–56)
- Challenge 33: Ten Million Dollar Benchmark — Running Totals & Window Functions (Cumulative revenue milestones per fiscal year)
- Challenge 34: The Mentors — Ranking & Row Pairing (Pairing highest and lowest performing salespeople by revenue)
- Challenge 35: Year-over-Year Comparisons — Period-over-Period Analysis (Fiscal-quarter sales comparisons across consecutive years)
- Challenge 36: Date Range Gaps — Sequential Row Comparison (Detecting price history date gaps between EndDate and StartDate)
- Challenge 37: Company Picnic — String Concatenation & Latest Rows (Employee names formatted with current department assignment)
- Challenge 38: Sales Reasons — Ranking Extremes (Sales reasons tied for highest or lowest frequency)
- Challenge 39: Revenue Trended — Date Math & Forecasting (Projecting full-month revenue from partial-month data)
- Challenge 40: Featured Product Reviews — String Splitting & Word Matching (Matching review terms to product titles)
- Challenge 41: Employment Survey — NTILE & Demographic Aggregation (Workforce tenure across quartiles)
- Challenge 42: Costs Vary — Variance Analysis & Ranking (Product cost variability rankings)
- Challenge 43: Expired Credit Cards — Date Construction & Conditional Counts (Order volume before vs. after credit card expiration)
- Challenge 44: Median Revenue — Percentile Analytics (Min, median, average, and max sales amounts per calendar year)
- Challenge 45: Product Combinations — Basket Analysis (Sales order combinations of bikes, accessories, and clothing)
- Challenge 46: Product Description Language Survey — Conditional Aggregation & Pivoting (Product description language grid)
- Challenge 47: Similar Products — Closest-Match Retrieval (Finding closest-priced alternative products by size and style)
- Challenge 48: Trade Show Giveaway — Combination Search & Ranking (Three-product bundles under $120 budget)
- Challenge 49: Online/Offline — Conditional Aggregation (Percentage of orders placed online versus offline by territory)
- Challenge 50: Pay Rate Changes — Previous-Row Analysis (Percentage change calculated against immediate preceding pay rate)
- Challenge 51: Sales Quota Changes — Earliest/Latest Row Comparison (Sales quota percentage change between 2013 and 2014)
- Challenge 52: Age Groups — CASE Bucketing (Employee age ranges and pay rates by job title)
- Challenge 53: Overpaying — Ranked Distinct Values (Finding highest and second-highest distinct vendor prices)
- Challenge 54: Sales Order Counts — PIVOT & Fiscal-Year Analysis (Salesperson order counts pivoted across fiscal years)
- Challenge 55: Orphan Products/Vendors — FULL JOIN & Orphan Detection (Product-vendor mapping and unassociated entity detection)
- Challenge 56: Calendar of Work Days — Calendar Table Generation (Reusable calendar with weekdays and federal holidays)
Bonus: SQL Thought Experiments
- Challenge B1: Simple Twist of Fate — OUTER APPLY & Random Row Selection
- Challenge B2: Friend of the Devil — String Parsing & Relationship Matching
Book Errata & Updates
Current status for Real SQL Queries: 50 Challenges (Anniversary Edition): No known errata or unresolved issues reported. For technical queries or errata submissions, contact Brian Cohen directly at cohenbrian@gmail.com.
Creator of Surreal SQL
Educational video series retraining analytical minds to see the world as relational tables, blending SQL, databases, and cinematic aesthetics. Featured episodes explore songs as data, lyrics as logic, and music as relational tables (including The Cardigans "Erase / Rewind", Taylor Swift, Rush, and Pink Floyd).
Watch Surreal SQL on YouTube (@SurrealSQL)
Recent Writing
What Listening Looks Like — Micro nonfiction piece following a YouTube reactor discovering Pink Floyd, one song at a time. Publishing in Hobart on September 10, 2026.
Legal & Privacy
This portfolio website respects user privacy. No personally identifiable information (PII) is sold or shared with third parties. Anonymous telemetry is collected strictly for site performance and layout optimization via Google Analytics.
Connect
LinkedIn (@sqlbrian) |
GitHub (@sqlbrian) |
YouTube (@SurrealSQL) |
cohenbrian@gmail.com