Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CASE STATEMENT AS CLAUSE 1

Status
Not open for further replies.

cristi22

MIS
Aug 17, 2005
155
US
Hello all -
db2 udb 9.2
Can anyone please tell me why 'AS'does not work ?
Code:
SELECT  
usr_empl_name
, count   (case when usr_empl_name  = 'UMASS DART'   and  coverage_code = 'C'  and benefit_plan = 'DOHIGH'   then member_ssn   end)   [COLOR=RED] as 'UMASS_DART_SINGLE_HIGH'[/COLOR]
, count   (case when usr_empl_name = 'UMASS MEDICAL'    and  coverage_code = 'C'  and benefit_plan = 'DOHIGH'  then  member_ssn   end) 
, count  (case when usr_empl_name = 'UMASS MEMORIAL' and  coverage_code = 'C'  and benefit_plan = 'DOHIGH'  then   member_ssn   end)  

                , case coverage_code when 'C' then 'SINGLE ENROLLED' when 'A' then 'FAMILY ENROLLED' else 'NULL'   end
                , case benefit_plan when 'DOSTAN' then 'STANDARD' when 'DOHIGH' then 'HIGH' else 'NULL' end
                , count(member_ssn) as members      
        FROM
                        elg_summary , umass_empl
        WHERE
                employer=empl
                and ben_date = DATE('2005-07-01')
                and dep_name = '' and  dep_ssn = ''
                and coverage_code <> 'D'
                and  benefit_plan in ('DOSTAN','DOHIGH')
        GROUP BY
                usr_empl_name
               ,  benefit_plan
               ,  coverage_code
               ,  ben_date

thanks for your help
error:

SQL0104N An unexpected token "'UMASS_DART_SINGLE_HIGH'" was
found following "ber_ssn end) as". Expected tokens may
include: "<space> ".
 
I am not sure what the "disregard" meant - if you figured it out or if you are saying 'disregard "" '.

Anyways, the reason for the error is that you have the alias in quotes.
as UMASS_DART_SINGLE_HIGH --No quotes around UMASS_DART_SINGLE_HIGH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top