Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor III
Contributor III

SQL Select case statement to alias field data

I have a sql script that loads data for reporting.  I would like to alias the data in one of the fields so that the output is slightly different.   if I do not use the field below (in blue) the data loads perfectly.   What am I doing incorrectly here?  

SQL SELECT DISTINCT substr(PAIDDATE,1,6),
PAIDMONTH,
COUNTYCODE = CASE
WHEN A.GROUPCODE='HCBUC' THEN 'BUCKS'
WHEN A.GROUPCODE='HCDLW' THEN 'DELAWARE'
WHEN A.GROUPCODE='HCMTG' THEN 'MONTGOMERY'
END,
A.GROUPCODE,
RATEGROUPDESC,
PROVIDERMISID,
A.SERVICECATEGORYCODE,
SERVICECATEGORYDESC,
SERVICESTARTMONTH,
PAIDDATE,
TOTALPAIDAMOUNT,
UNIQUEMEMBERCOUNT,
UNITS,
PAIDAMOUNT
FROM TBL1 A, TBL2 B, TBL3 C
WHERE PAIDDATE between 20180701 and 20180731
AND A.RATEGROUPCODE = B.RATEGROUPCODE
AND A.SERVICECATEGORYCODE = SUBSTR(C.SERVICECATEGORYCODE,1,2)
ORDER BY substr(PAIDDATE,1,6),A.GROUPCODE, PROVIDERMISID,RATEGROUPDESC, PAIDDATE;

1 Solution

Accepted Solutions
Highlighted
Partner
Partner

Depends on the SQL you're using, but should be actually something like

case COUNTYCODE

when 'HCBUC' THEN 'BUCKS'

when 'HCDLW' THEN 'DELAWARE'

when 'HCMTG' THEN 'MONTGOMERY'

end 

Felipe.

 

View solution in original post

2 Replies
Highlighted
Partner
Partner

Depends on the SQL you're using, but should be actually something like

case COUNTYCODE

when 'HCBUC' THEN 'BUCKS'

when 'HCDLW' THEN 'DELAWARE'

when 'HCMTG' THEN 'MONTGOMERY'

end 

Felipe.

 

View solution in original post

Highlighted
Contributor III
Contributor III

yes that was it...silly mistake.  thank you!