| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- USE AdventureWorksDW2008R2
- GO
- DECLARE @maxWeight float, @productKey integer
- SET @maxWeight = 100.00
- SET @productKey = 424
- IF @maxWeight <= (SELECT Weight from DimProduct
- WHERE ProductKey = @productKey)
- (SELECT @productKey AS ProductKey, EnglishDescription, Weight,
- 'This product is too heavy to ship and is only available for pickup.'
- AS ShippingStatus
- FROM DimProduct WHERE ProductKey = @productKey);
- ELSE
- (SELECT @productKey AS ProductKey, EnglishDescription, Weight,
- 'This product is available for shipping or pickup.'
- AS ShippingStatus
- FROM DimProduct WHERE ProductKey = @productKey);
- GO
- SELECT 'The list price is ' + CAST(ListPrice AS varchar(12)) AS ListPrice
- FROM dbo.DimProduct
- WHERE ListPrice BETWEEN 350.00 AND 400.00;
- GO
- SELECT OrderDateKey, SUM(SalesAmount) AS TotalSales FROM FactInternetSales
- GROUP BY OrderDateKey ORDER BY OrderDateKey;
- GO
- SELECT LastName, FirstName FROM DimCustomer GROUP BY LastName, FirstName;
- GO
- SELECT NumberCarsOwned FROM DimCustomer GROUP BY YearlyIncome, NumberCarsOwned;
- GO
- SELECT (SalesAmount + TaxAmt + Freight) AS TotalCost FROM FactInternetSales GROUP BY SalesAmount, TaxAmt, Freight;
- GO
- SELECT SalesAmount, SalesAmount*1.10 SalesTax FROM FactInternetSales GROUP BY SalesAmount;
- GO
- SELECT SalesAmount FROM FactInternetSales GROUP BY SalesAmount, SalesAmount*1.10;
- GO
- SELECT OrderDateKey, SUM(SalesAmount) AS TotalSales
- FROM FactInternetSales
- GROUP BY OrderDateKey
- HAVING OrderDateKey > 20040000
- ORDER BY OrderDateKey;
- GO
- SELECT TOP (10) r.ResellerName, r.AnnualSales
- FROM DimReseller AS r
- ORDER BY AnnualSales DESC, ResellerName ASC;
- GO
- SELECT *
- FROM FactInternetSales fis INNER JOIN DimProduct dp ON fis.ProductKey = dp.ProductKey
- WHERE CurrencyKey = 98 AND SalesTerritoryKey = 10
- GO
- EXEC usp_GetSales 98, 10
- GO
- EXEC usp_GetProdCostMSRP 1000, 2000
- GO
|