# Function: ufn_SalesByStore

## Properties

Property | Value
--- | ---
Name | ufn_SalesByStore
ID | 455672671
Schema | Sales
Owner | dbo
Execute As | Caller
Type | SQL INLINE TABLE VALUED FUNCTION
Uses Ansi Nulls |
Uses Quoted Identifier |
Is Schema Bound |
Uses Database Collation |
Null on Null Input |
Encrypted |
MS Shipped |
Published |
Schema Published |
Deterministic |
Precise |
System Verified |
System Data Access |
User Data Access |
Modify Date | 12/21/2010 5:27:26 AM
Creation Date | 12/21/2010 5:27:26 AM

## Extended Properties

Name | Value
--- | ---
MS_Description | aggregate function - mobi mobi czwartek

## Permissions

No object level permissions defined.

## Parameters

Parameter Name | Datatype | Has Default Value | Default Value | Read Only | Xml Document | Description
--- | --- | --- | --- | --- | --- | ---
@storeid | int |  |  |  |  |

## Recordset Returned

No resulting record sets.

## Objects that depend on [ufn_SalesByStore]

- Sales.ufn_SalesByStore

## Objects on which [ufn_SalesByStore] depends

- Sales.ufn_SalesByStore
  - Production.Product
    - dbo.Flag
    - dbo.Name
    - Production.ProductModel
      - Production.ManuInstructionsSchemaCollection
      - Production.ProductDescriptionSchemaCollection
    - Production.ProductSubcategory
      - Production.ProductCategory
    - Production.UnitMeasure
  - Sales.SalesOrderDetail
    - dbo.uspLogError
      - dbo.ErrorLog
      - dbo.uspPrintError
    - Person.Person
      - dbo.NameStyle
      - Demographics.exist
      - Person.AdditionalContactInfoSchemaCollection
      - Person.BusinessEntity
      - Person.IndividualSurveySchemaCollection
    - Production.TransactionHistory
      - datePS
        - dataPF1
    - Sales.Customer
      - dbo.ufnLeadingZeros
      - Sales.SalesTerritory
        - Person.CountryRegion
      - Sales.Store
        - Sales.SalesPerson
          - HumanResources.Employee
        - Sales.StoreSurveySchemaCollection
    - Sales.SalesOrderHeader
      - dbo.AccountNumber
      - dbo.OrderNumber
      - dbo.ufnGetAccountingEndDate
      - dbo.ufnGetAccountingStartDate
      - Person.Address
        - Person.StateProvince
      - Purchasing.ShipMethod
      - Sales.CreditCard
      - Sales.CurrencyRate
        - Sales.Currency
    - Sales.SpecialOfferProduct
      - Sales.SpecialOffer

## SQL

Script
SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON CREATE FUNCTION Sales.ufn_SalesByStore (@storeid int) RETURNS TABLE AS RETURN ( SELECT P.ProductID, P.Name, SUM(SD.LineTotal) AS 'YTD Total' FROM Production.Product AS P JOIN Sales.SalesOrderDetail AS SD ON SD.ProductID = P.ProductID JOIN Sales.SalesOrderHeader AS SH ON SH.SalesOrderID = SD.SalesOrderID WHERE SH.CustomerID = @storeid GROUP BY P.ProductID, P.Name ); EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'aggregate function - mobi mobi czwartek' , @level0type=N'SCHEMA',@level0name=N'Sales', @level1type=N'FUNCTION',@level1name=N'ufn_SalesByStore'

#### See also

List of Functions