Case when...

  • Trying to "case" into the same column 'Department'. I'm obviously a Newbie as this is producing two "Department" columns. Tried one Case Statement with some "Or" but it wasn't working. Any help is appreciated.

    SELECT [EncounterKey]

    ,[MedRecNo]

    ,[AccountKey]

    ,[DischargeDateTime]

    ,[DateOfService]

    ,[PrimaryInsPlan]

    ,[DivisionDesc]

    ,[InpatientOutpatientInd]

    ,[PatientType]

    ,[DepartmentNumber]

    ,[EDFlag]

    ,[ChargeAmount]

    case when

    (departmentnumber in (091111,011111)) then 'Emergency' else '' end as Department,

    case when

    (departmentnumber in (013121)) then 'NICU' else '' end as Department

    From [database1]

    where [departmentnumber] in (091111,011111,013121)

  • ahh, nevermind..answer was a few questions below...

  • Just one case:

    case when (departmentnumber in (091111,011111)) then 'Emergency'

    when (departmentnumber in (013121)) then 'NICU'

    else ''

    end as Department

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

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