none
Select First instance of a value RRS feed

  • Question

  • Hi all,

    PLease see below:

    DECLARE @temp TABLE

    (

      ID int
    ,  Title nvarchar(255)
    , DescriptionName nvarchar(255)
    , VALUE int
    )

    INSERT INTO
     @temp
     
     SELECT 1, 'Test1', 'TestDescription1', 1
     
     INSERT INTO
     @temp
     
     SELECT 1, 'Test1', 'TestDescription1', 4
     
     INSERT INTO
     @temp
     
     SELECT 2, 'Test2', 'TestDescription2', 2
     
     INSERT INTO
     @temp
     
     SELECT 2, 'Test2', 'TestDescription2', 3
     
     SELECT * FROM @TEMP


    ID Title DescriptionName VALUE
    1 Test1 TestDescription1 1
    1 Test1 TestDescription1 4
    2 Test2 TestDescription2 2
    2 Test2 TestDescription2 3

    I would like to return the following

    ID Title DescriptionName VALUE
    1 Test1 TestDescription1 1
    2 Test2 TestDescription2 2

    I will always have two of the same id's I would like to pick the first instance of this ID.

    please help me.

    Saturday, March 17, 2012 9:28 PM

Answers

All replies