[Stackoverflow] [Progress OpenEdge ABL] Better way to write Case When Multiple conditions

Status
Not open for further replies.
J

Jack Williams

Guest
I have have written the below query to help me segment my data into different cells. This has over 200 conditions so i have only provided a small sample. Is there a better way for me to write this statement because from research Progress will not let me do more than 50 CASE WHEN....THEN statements.

SELECT

Company_0.CompanyID
,Company_0.CoaCompanyName
,(CASE
WHEN Company_0.CompanyID = 7942127 THEN 'BLUE'
WHEN Company_0.CompanyID = 7950986 THEN 'BLUE'
WHEN Company_0.CompanyID = 7955733 THEN 'BLUE'
WHEN Company_0.CompanyID = 7955922 THEN 'BLUE'
WHEN Company_0.CompanyID = 7956194 THEN 'RED'
WHEN Company_0.CompanyID = 9166261 THEN 'RED'
WHEN Company_0.CompanyID = 9167003 THEN 'YELLOW'
WHEN Company_0.CompanyID = 9167015 THEN 'YELLOW
ELSE NULL
END' AS 'CELL'


When the results are returned it should look something like this:

ID COMPANY NAME CELL
-------------------------------------------------------
7942127 A BLUE
7950986 B BLUE
7955733 C BLUE
7955922 D BLUE
7956194 E RED
9166261 F RED
9167003 G YELLOW
9167015 H YELLOW

Continue reading...
 
Status
Not open for further replies.
Top