SQLforGeeks
  • Home
  • SQL
  • SQL Tutorial
  • SQL Syntax
  • Our Services
Contact
  1. SQL
  2. CHOOSE function

Text copied!

« Previous
Next »

CHOOSE function

June 25, 2023, 8:28 p.m. under SQL

  • Hi! You should check IIF function post first.

    In SQL, the CHOOSE function allows you to select and return a value from a list of values based on a specified index

    The CHOOSE function in SQL Server helps you pick a specific value from a list of options. You just tell it which position in the list you want, and it gives you the value at that spot. It's like choosing a candy from a box by saying which number candy you want.

    The syntax of the CHOOSE function generally looks like this :
    CHOOSE (index, value1, value2, value3, ..., valueN)
            

    • index: The position of the option you want to choose.

    • value1, value2, value3, ..., valueN: The list of options to choose from. These could be values, columns, or expressions.

    Here's an example of how you might use the CHOOSE function :

    1. Consider a list of values comprising January, February, March, and April.

    2. Let's assume you want to get the value at position 3.

    3. Run below SQL statement :

    SELECT CHOOSE(3, 'January', 'February', 'March', 'April');
            

    4. In this example, This query would return 'March' because it selects the value at the third index.

    CHOOSE function
    Make sure to keep an eye out for our next tutorial on SQL stored procedures.

    Frequently Asked Questions :

    How do I SELECT a function in SQL?

    To SELECT a function in SQL, you specify the function name followed by the appropriate parameters within the SELECT statement.

    What is choose in SQL Server?

    "Choose" in SQL Server is not a specific keyword or function. Perhaps you meant something else?

    How do you choose between two values in SQL?

    To choose between two values in SQL, you can use the CASE statement or the COALESCE function, depending on the specific scenario.

    When to choose SQL?

    SQL is chosen when you need to interact with relational databases to retrieve, manipulate, or manage data efficiently.
    Thank You! You should check SQL Store Procedure post next.
    « Previous
    Next »
    RELATED :

    What is SQL

    What is T-SQL

    Difference between DBMS and Data Warehouse

    Download SQL Server

    Install SQL Server

    Download SQL Server Management Studio SSMS

    SQL Server Management Studio

    SQL Database

    Download database

    Restore database

    Backup database

    Attach database

    Detach database

    Create database

    Delete database

    Rename database

    Select database

    Database offline

    Database online

    SQL Commands

    SQL Tables

    Create table

    Truncate table

    Delete table

    Rename table

    Select table

    Alter table

    SQL Data Types

    SQL Comments

    SQL Constraints

    SQL Joins

    SQL inner join

    SQL left join

    SQL right join

    SQL full join

    SQL cross join

    SQL self join

    INSERT INTO SELECT statement

    INSERT INTO statement

    SQL Clauses

    SELECT clause

    FROM clause

    WHERE clause

    GROUP BY clause

    HAVING clause

    ORDER BY clause

    JOIN clause

    UNION clause

    UNION ALL clause

    TOP clause

    DISTINCT clause

    SQL Operators

    SQL Arithmetic operators

    SQL Comparison operators

    SQL Logical operators

    UNION operator

    UNION ALL operator

    INTERSECT operator

    EXCEPT operator

    LIKE operator

    NOT LIKE operator

    IN operator

    NOT IN operator

    IS NULL operator

    IS NOT NULL operator

    EXISTS operator

    NOT EXISTS operator

    BETWEEN operator

    NOT BETWEEN operator

    SQL Functions

    SQL Built-In functions

    CHARINDEX function

    DATEADD function

    CONCAT function

    LEN function

    REPLACE function

    SUBSTRING function

    CASE statement

    GETDATE function

    DATEPART function

    DATEDIFF function

    CAST function

    TRY_CAST function

    CONVERT function

    TRY_CONVERT function

    ISNULL function

    NULLIF function

    COALESCE function

    SQL Window functions

    ROW_NUMBER function

    RANK function

    DENSE_RANK function

    IIF function

    SQL Store Procedure

    Store Procedure vs. Function

    SQL Subquery

    SQL Aliases

    Temp table

    SQL Error Handling

    SQL Variables

    SQL Views

    SQL Merge

    SQL CTE

    SQL WITH TIES

    Define Transaction in DBMS

    ACID properties in DBMS

    Types of Triggers in DBMS


    • Have Some Questions?
    logo

    Elevate your data experience with SQL excellence

    Quick Links
    •  Home
    •  SQL Tutorial
    •  SQL Syntax
    •  Our Services
    Our Services
    • Web Development
    • BI Development
    • Data Warehousing
    • Data Integration ETL


    Follow Us

    GST Registered: XXAXXXXXXXZX
    Mumbai, Maharashtra, India support@sqlforgeeks.com

    © 2025 Copyright™ | All Rights Reserved | Privacy Policy