Workload.sql 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. USE AdventureWorksDW2008R2
  2. GO
  3. DECLARE @maxWeight float, @productKey integer
  4. SET @maxWeight = 100.00
  5. SET @productKey = 424
  6. IF @maxWeight <= (SELECT Weight from DimProduct
  7. WHERE ProductKey = @productKey)
  8. (SELECT @productKey AS ProductKey, EnglishDescription, Weight,
  9. 'This product is too heavy to ship and is only available for pickup.'
  10. AS ShippingStatus
  11. FROM DimProduct WHERE ProductKey = @productKey);
  12. ELSE
  13. (SELECT @productKey AS ProductKey, EnglishDescription, Weight,
  14. 'This product is available for shipping or pickup.'
  15. AS ShippingStatus
  16. FROM DimProduct WHERE ProductKey = @productKey);
  17. GO
  18. SELECT 'The list price is ' + CAST(ListPrice AS varchar(12)) AS ListPrice
  19. FROM dbo.DimProduct
  20. WHERE ListPrice BETWEEN 350.00 AND 400.00;
  21. GO
  22. SELECT OrderDateKey, SUM(SalesAmount) AS TotalSales FROM FactInternetSales
  23. GROUP BY OrderDateKey ORDER BY OrderDateKey;
  24. GO
  25. SELECT LastName, FirstName FROM DimCustomer GROUP BY LastName, FirstName;
  26. GO
  27. SELECT NumberCarsOwned FROM DimCustomer GROUP BY YearlyIncome, NumberCarsOwned;
  28. GO
  29. SELECT (SalesAmount + TaxAmt + Freight) AS TotalCost FROM FactInternetSales GROUP BY SalesAmount, TaxAmt, Freight;
  30. GO
  31. SELECT SalesAmount, SalesAmount*1.10 SalesTax FROM FactInternetSales GROUP BY SalesAmount;
  32. GO
  33. SELECT SalesAmount FROM FactInternetSales GROUP BY SalesAmount, SalesAmount*1.10;
  34. GO
  35. SELECT OrderDateKey, SUM(SalesAmount) AS TotalSales
  36. FROM FactInternetSales
  37. GROUP BY OrderDateKey
  38. HAVING OrderDateKey > 20040000
  39. ORDER BY OrderDateKey;
  40. GO
  41. SELECT TOP (10) r.ResellerName, r.AnnualSales
  42. FROM DimReseller AS r
  43. ORDER BY AnnualSales DESC, ResellerName ASC;
  44. GO
  45. SELECT *
  46. FROM FactInternetSales fis INNER JOIN DimProduct dp ON fis.ProductKey = dp.ProductKey
  47. WHERE CurrencyKey = 98 AND SalesTerritoryKey = 10
  48. GO
  49. EXEC usp_GetSales 98, 10
  50. GO
  51. EXEC usp_GetProdCostMSRP 1000, 2000
  52. GO