Sample
Queries

Ready-to-use SQL queries for exploring AdventureWorks data. Copy, modify, and run these queries to understand your bicycle business data.

Query Categories

Explore 16 sample queries organized by business function

Sales Analysis

2 queries

Channel Sales

1 queries

Financial Analysis

2 queries

Inventory Management

2 queries

Product Information

2 queries

Operations

1 queries

Internet Sales Overview

Sales Analysis

This query retrieves key details of online sales transactions, including customer, product, and territory information.

SQL Query
SELECT 
    f.SalesOrderNumber, 
    dDate.CalendarYear, 
    dCustomer.FirstName + ' ' + dCustomer.LastName AS CustomerName, 
    dProduct.EnglishProductName, 
    dSalesTerritory.SalesTerritoryRegion, 
    f.OrderQuantity, 
    f.UnitPrice, 
    f.SalesAmount 
FROM 
    FactInternetSales AS f 
JOIN 
    DimDate AS dDate ON f.OrderDateKey = dDate.DateKey 
JOIN 
    DimCustomer AS dCustomer ON f.CustomerKey = dCustomer.CustomerKey 
JOIN 
    DimProduct AS dProduct ON f.ProductKey = dProduct.ProductKey 
JOIN 
    DimSalesTerritory AS dSalesTerritory ON f.SalesTerritoryKey = dSalesTerritory.SalesTerritoryKey;

Reseller Sales Overview

Channel Sales

This query focuses on sales made through resellers, providing insights into reseller names, products, and sales territories.

SQL Query
SELECT 
    f.SalesOrderNumber, 
    dDate.CalendarYear, 
    dReseller.ResellerName, 
    dProduct.EnglishProductName, 
    dSalesTerritory.SalesTerritoryCountry, 
    f.OrderQuantity, 
    f.SalesAmount 
FROM 
    FactResellerSales AS f 
JOIN 
    DimDate AS dDate ON f.OrderDateKey = dDate.DateKey 
JOIN 
    DimReseller AS dReseller ON f.ResellerKey = dReseller.ResellerKey 
JOIN 
    DimProduct AS dProduct ON f.ProductKey = dProduct.ProductKey 
JOIN 
    DimSalesTerritory AS dSalesTerritory ON f.SalesTerritoryKey = dSalesTerritory.SalesTerritoryKey;

Call Center Daily Performance

Operations

This query extracts operational metrics for the call center, useful for tracking daily performance.

SQL Query
SELECT 
    dDate.FullDateAlternateKey AS ReportDate, 
    f.Calls, 
    f.TotalOperators, 
    f.ServiceGrade 
FROM 
    FactCallCenter AS f 
JOIN 
    DimDate AS dDate ON f.DateKey = dDate.DateKey;

Product Inventory Movements

Inventory Management

This query provides a detailed view of product inventory changes, showing units received, shipped, and current balance.

SQL Query
SELECT 
    f.MovementDate, 
    dProduct.EnglishProductName, 
    f.UnitsIn, 
    f.UnitsOut, 
    f.UnitsBalance 
FROM 
    FactProductInventory AS f 
JOIN 
    DimProduct AS dProduct ON f.ProductKey = dProduct.ProductKey 
JOIN 
    DimDate AS dDate ON f.DateKey = dDate.DateKey;

Financial Transactions

Financial Analysis

This query allows for an overview of financial transactions, categorized by organization, department, scenario, and account type.

SQL Query
SELECT 
    dDate.FullDateAlternateKey AS TransactionDate, 
    dOrganization.OrganizationName, 
    dDepartmentGroup.DepartmentGroupName, 
    dScenario.ScenarioName, 
    dAccount.AccountDescription, 
    f.Amount 
FROM 
    FactFinance AS f 
JOIN 
    DimDate AS dDate ON f.DateKey = dDate.DateKey 
JOIN 
    DimOrganization AS dOrganization ON f.OrganizationKey = dOrganization.OrganizationKey 
JOIN 
    DimDepartmentGroup AS dDepartmentGroup ON f.DepartmentGroupKey = dDepartmentGroup.DepartmentGroupKey 
JOIN 
    DimScenario AS dScenario ON f.ScenarioKey = dScenario.ScenarioKey 
JOIN 
    DimAccount AS dAccount ON f.AccountKey = dAccount.AccountKey;

Sales Quotas by Employee

Performance Tracking

This query retrieves sales quota information, linking employees to their annual and quarterly targets.

SQL Query
SELECT 
    dEmployee.FirstName + ' ' + dEmployee.LastName AS EmployeeName, 
    dDate.CalendarYear, 
    dDate.CalendarQuarter, 
    f.SalesAmountQuota 
FROM 
    FactSalesQuota AS f 
JOIN 
    DimEmployee AS dEmployee ON f.EmployeeKey = dEmployee.EmployeeKey 
JOIN 
    DimDate AS dDate ON f.DateKey = dDate.DateKey;

Survey Responses Summary

Customer Feedback

This query aggregates customer survey responses, providing counts by date, customer, and product category.

SQL Query
SELECT 
    dDate.FullDateAlternateKey AS SurveyDate, 
    dCustomer.FirstName + ' ' + dCustomer.LastName AS CustomerName, 
    dProductCategory.EnglishProductCategoryName, 
    COUNT(*) AS ResponseCount 
FROM 
    FactSurveyResponse AS f 
JOIN 
    DimCustomer AS dCustomer ON f.CustomerKey = dCustomer.CustomerKey 
JOIN 
    DimProductCategory AS dProductCategory ON f.ProductCategoryKey = dProductCategory.ProductCategoryKey 
JOIN 
    DimDate AS dDate ON f.DateKey = dDate.DateKey 
GROUP BY 
    dDate.FullDateAlternateKey, dCustomer.FirstName, dCustomer.LastName, dProductCategory.EnglishProductCategoryName;

Daily Currency Exchange Rates

Financial Analysis

This query provides a snapshot of average and end-of-day currency exchange rates for specific dates.

SQL Query
SELECT 
    dDate.FullDateAlternateKey AS RateDate, 
    f.CurrencyKey, 
    f.AverageRate, 
    f.EndOfDayRate 
FROM 
    FactCurrencyRate AS f 
JOIN 
    DimDate AS dDate ON f.DateKey = dDate.DateKey;

Product Inventory Summary

Inventory Management

This query summarizes total units in and out for each product, useful for high-level inventory tracking.

SQL Query
SELECT 
    dProduct.EnglishProductName, 
    SUM(f.UnitsIn) AS TotalUnitsIn, 
    SUM(f.UnitsOut) AS TotalUnitsOut 
FROM 
    FactProductInventory AS f 
JOIN 
    DimProduct AS dProduct ON f.ProductKey = dProduct.ProductKey 
GROUP BY 
    dProduct.EnglishProductName;

International Product Descriptions

Product Information

This query helps to retrieve localized product descriptions for multi-lingual reporting.

SQL Query
SELECT 
    f.ProductKey, 
    dProduct.EnglishProductName, 
    f.CultureName, 
    f.ProductDescription 
FROM 
    FactAdditionalInternationalProductDescription AS f 
JOIN 
    DimProduct AS dProduct ON f.ProductKey = dProduct.ProductKey;

Internet Sales Reasons

Sales Analysis

This query links internet sales orders to the specific reasons or promotions that influenced the purchase.

SQL Query
SELECT 
    f.SalesOrderNumber, 
    f.SalesOrderLineNumber, 
    dSalesReason.SalesReasonName 
FROM 
    FactInternetSalesReason AS f 
JOIN 
    DimSalesReason AS dSalesReason ON f.SalesReasonKey = dSalesReason.SalesReasonKey;

Currency Dimension Lookup

Reference Data

A simple lookup query for currency names and their keys.

SQL Query
SELECT 
    dCurrency.CurrencyKey, 
    dCurrency.CurrencyName 
FROM 
    DimCurrency AS dCurrency;

Product Subcategory Details

Product Information

This query shows the hierarchical relationship between product subcategories and their parent categories.

SQL Query
SELECT 
    dSub.ProductSubcategoryKey, 
    dSub.EnglishProductSubcategoryName, 
    dCat.EnglishProductCategoryName AS ParentCategory 
FROM 
    DimProductSubcategory AS dSub 
JOIN 
    DimProductCategory AS dCat ON dSub.ProductCategoryKey = dCat.ProductCategoryKey;

Promotions Overview

Marketing

This query provides a summary of all available promotional campaigns, including their discount percentages and validity dates.

SQL Query
SELECT 
    dPromo.PromotionKey, 
    dPromo.EnglishPromotionName, 
    dPromo.DiscountPct, 
    dPromo.StartDate, 
    dPromo.EndDate 
FROM 
    DimPromotion AS dPromo;

Geographic Details

Geographic Analysis

This query provides detailed geographic information, useful for sales territory and customer location analysis.

SQL Query
SELECT 
    dGeo.GeographyKey, 
    dGeo.City, 
    dGeo.StateProvinceName, 
    dGeo.EnglishCountryRegionName AS Country 
FROM 
    DimGeography AS dGeo;

Prospective Buyers Information

Lead Management

This query retrieves contact and demographic information for potential customers.

SQL Query
SELECT 
    pb.ProspectiveBuyerKey, 
    pb.FirstName + ' ' + pb.LastName AS BuyerName, 
    pb.EmailAddress, 
    pb.YearlyIncome, 
    pb.City, 
    pb.StateProvinceCode 
FROM 
    ProspectiveBuyer AS pb;