--- title: "CHOOSE (Transact-SQL) | Microsoft Docs" ms.custom: "" ms.date: "03/14/2017" ms.prod: "sql-non-specified" ms.reviewer: "" ms.suite: "" ms.technology: - "database-engine" ms.tgt_pltfrm: "" ms.topic: "language-reference" f1_keywords: - "CHOOSE" - "CHOOSE_TSQL" dev_langs: - "TSQL" helpviewer_keywords: - "CHOOSE function" ms.assetid: 1c382c83-7500-4bae-bbdc-c1dbebd3d83f caps.latest.revision: 13 author: "BYHAM" ms.author: "rickbyh" manager: "jhubbard" --- # Logical Functions - CHOOSE (Transact-SQL) [!INCLUDE[tsql-appliesto-ss2012-asdb-xxxx-xxx_md](../../includes/tsql-appliesto-ss2012-asdb-xxxx-xxx-md.md)] Returns the item at the specified index from a list of values in [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. ![Topic link icon](../../database-engine/configure-windows/media/topic-link.gif "Topic link icon") [Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md) ## Syntax ``` CHOOSE ( index, val_1, val_2 [, val_n ] ) ``` ## Arguments *index* Is an integer expression that represents a 1-based index into the list of the items following it. If the provided index value has a numeric data type other than **int**, then the value is implicitly converted to an integer. If the index value exceeds the bounds of the array of values, then CHOOSE returns null. *val_1 … val_n* List of comma separated values of any data type. ## Return Types Returns the data type with the highest precedence from the set of types passed to the function. For more information, see [Data Type Precedence (Transact-SQL)](../../t-sql/data-types/data-type-precedence-transact-sql.md). ## Remarks CHOOSE acts like an index into an array, where the array is composed of the arguments that follow the index argument. The index argument determines which of the following values will be returned. ## Examples The following example returns the third item from the list of values that is provided. ``` SELECT CHOOSE ( 3, 'Manager', 'Director', 'Developer', 'Tester' ) AS Result; ``` [!INCLUDE[ssResult](../../includes/ssresult-md.md)] ``` Result ------------- Developer (1 row(s) affected) ``` The following example returns a simple character string based on the value in the `ProductCategoryID` column. ``` USE AdventureWorks2012; GO SELECT ProductCategoryID, CHOOSE (ProductCategoryID, 'A','B','C','D','E') AS Expression1 FROM Production.ProductCategory; ``` [!INCLUDE[ssResult](../../includes/ssresult-md.md)] ``` ProductCategoryID Expression1 ----------------- ----------- 3 C 1 A 2 B 4 D (4 row(s) affected) ``` The following example returns the quarter in which an employee was hired. The MONTH function is used to return the month value from the column `HireDate`. ``` USE AdventureWorks2012; GO SELECT JobTitle, HireDate, CHOOSE(MONTH(HireDate),'Winter','Winter', 'Spring','Spring','Spring','Summer','Summer', 'Summer','Autumn','Autumn','Autumn','Winter') AS Quarter_Hired FROM HumanResources.Employee WHERE YEAR(HireDate) > 2005 ORDER BY YEAR(HireDate); ``` [!INCLUDE[ssResult](../../includes/ssresult-md.md)] ``` JobTitle HireDate Quarter_Hired -------------------------------------------------- ---------- ------------- Sales Representative 2006-11-01 Autumn European Sales Manager 2006-05-18 Spring Sales Representative 2006-07-01 Summer Sales Representative 2006-07-01 Summer Sales Representative 2007-07-01 Summer Pacific Sales Manager 2007-04-15 Spring Sales Representative 2007-07-01 Summer ``` ## See Also [IIF (Transact-SQL)](../../t-sql/functions/logical-functions-iif-transact-sql.md)