Query Help

  • Hello everyone,

    I need query help to build logic to my store procedure.

    below is the sample data

    create table #TEMP (SCHOOLID INT,

    TYPES VARCHAR(10),

    STATUS VARCHAR(10))

    INSERT INTO #TEMP VALUES (101,'TEST','YES')

    INSERT INTO #TEMP VALUES (101,'TEST1','NO')

    INSERT INTO #TEMP VALUES (101,'TEST2','NO')

    INSERT INTO #TEMP VALUES (102,'TEST','NO')

    INSERT INTO #TEMP VALUES (102,'TEST1','NO')

    INSERT INTO #TEMP VALUES (103,'TEST','NO')

    INSERT INTO #TEMP VALUES (103,'TEST1','NO')

    INSERT INTO #TEMP VALUES (103,'TEST2','YES')

    i need to build the logic to get status Yes for any type,

    desire output will be

    SCHOOLIDSTATUS

    101YES

    102NO

    103YES

    Please help me to build this.

    Thanks for your help.

  • SELECT

    SCHOOLID

    ,MAX(STATUS) STATUS

    FROM #TEMP

    GROUP BY SCHOOLID

    ORDER BY SCHOOLID

    John

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply