Set Based results question.....

  • You can advise SQL Server that the ConcStatus derived column exists by nesting the select in a from. This is easier to read if you indent the nested select.

    select *

    FROM

    ( -- Indent start here

    SELECT Permnum , stulink , schoolnum

    , FirstName , Lastname , Grade , Gender , Concschool

    , Concishome

    , Case

    WHEN (concschool = '')and (concishome = 'X') then 'FLAG'

    WHEN (schoolnum = concschool)and (concishome = 'X') then 'FLAG'

    WHEN (schoolnum = concschool)and (concishome 'X') then 'FLAG'

    Else 'OK'

    End

    AS ConcStatus

    FROM CONCTEST

    ) -- Indent End here

    as ConcTestWithFlag -- Name the derived table

    Where ConcTestWithFlag.ConcStatus = 'flag'

    ORDER BY permnum asc

    SQL = Scarcely Qualifies as a Language

  • You can advise SQL Server that the ConcStatus derived column exists by nesting the select in a from. This is easier to read if you indent the nested select.

    select *

    FROM

    ( -- Indent start here

    SELECT Permnum , stulink , schoolnum

    , FirstName , Lastname , Grade , Gender , Concschool

    , Concishome

    , Case

    WHEN (concschool = '')and (concishome = 'X') then 'FLAG'

    WHEN (schoolnum = concschool)and (concishome = 'X') then 'FLAG'

    WHEN (schoolnum = concschool)and (concishome 'X') then 'FLAG'

    Else 'OK'

    End

    AS ConcStatus

    FROM CONCTEST

    ) -- Indent End here

    as ConcTestWithFlag -- Name the derived table

    Where ConcTestWithFlag.ConcStatus = 'flag'

    ORDER BY permnum asc

    SQL = Scarcely Qualifies as a Language

  • Is there ameans to attach an excel spreadsheet with some generic data?   I'm looking .. but not seeing....

Viewing 3 posts - 16 through 17 (of 17 total)

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