Skip to content

Latest commit

Β 

History

History
52 lines (35 loc) Β· 2.23 KB

File metadata and controls

52 lines (35 loc) Β· 2.23 KB

πŸ—ƒοΈ SQL Query Practice

A set of advanced T-SQL query exercises against the BikeStores sample database

SQL Server T-SQL License


πŸ“– About the Project

This is a collection of T-SQL queries written against the well-known BikeStores sample database (production and sales schemas), focused on practicing intermediate-to-advanced querying techniques: recursive CTEs, window functions, join variations, date logic, and dynamic SQL.


🧱 What's Inside

# Technique Description
1 Recursive CTE Renders a threaded forum as an indented hierarchy
2 GROUP BY / HAVING Finds product names that appear more than once
3 ROW_NUMBER() Flags duplicate product rows for cleanup
4 JOIN + DISTINCT Lists products that have actually been ordered
5 RIGHT JOIN (anti-join) Finds products that were never ordered
6 JOIN + IN Filters products by a set of brand names
7 UNION ALL Combines customers and staff into one contact list
8 LIKE Filters customers by email domain
9 DATEDIFF + CASE Finds orders that took more than 2 days to ship (or haven't shipped yet)
10 EOMONTH Finds orders placed on the last day of their month
11 CTE + STRING_SPLIT + ROW_NUMBER() Gets each selected customer's most recent order, with computed line-item totals
12 Dynamic SQL (sp_executesql) Builds and runs a parameterized SELECT ... ORDER BY from column-name variables

πŸš€ Running the Queries

  1. Restore the BikeStores sample database on a SQL Server instance.
  2. Open queries.sql in SQL Server Management Studio (or Azure Data Studio).
  3. Run each numbered block independently β€” they don't depend on one another.

Built with πŸ—ƒοΈ by Ester-Developer