select rows if condition is true

  • Hello,

    Can this be done.

    I want to return distinct name if complete is true on all rows

    ID NAME COMPLETE

    1volvo True

    2volvo False

    3volvo True

    4saab True

    would return:

    saab true

    ID NAME COMPLETE

    1volvo True

    2volvo True

    3volvo True

    4saab True

    would return:

    volvo true

    saab true

    // Regards Tomas

  • Nils Andersson (1/27/2009)


    Hello,

    Can this be done.

    I want to return distinct name if complete is true on all rows

    ID NAME COMPLETE

    1volvo True

    2volvo False

    3volvo True

    4saab True

    would return:

    saab true

    ID NAME COMPLETE

    1volvo True

    2volvo True

    3volvo True

    4saab True

    would return:

    volvo true

    saab true

    // Regards Tomas

    select name, 'True' as Complete

    from table

    group by name

    having count(*) = sum( case when complete = 'true' then 1 else 0 end )


    * Noel

  • sweet!

    Thanks alot.

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

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