2013-07-09 38 views
0

我有列名为Project,Status,ColorProject下的每行都是唯一的,但是,状态可以是Approved,Rejected,Submitted等,并且每种状态类型都有唯一的颜色(即批准为绿色)。Excel列(不同)写入CASE语句

在另一片材,我需要能够创建选择每个不同的状态类型的情况下声明(更可以增加,因此它需要是动态的),并这样输出它的格式:

CASE WHEN "Project"."Current Status" = 'Submitted' THEN '#008000' 
WHEN "Project"."Current Status" = 'In Progress' THEN '#F1E87D' 
WHEN "Project"."Current Status" = 'Rejected' THEN '#CD0000' 
WHEN "Project"."Current Status" = 'Approved' THEN '#0000EB' 
Else "Project"."Current Status" END 

它用相应的颜色为我放置状态类型。

回答

0

也许这样的..

SELECT CASE "Project"."Current Status" 
    Case Is 'Submitted': '#008000' 
    Case Is 'In Progress': '#F1E87D' 
    Case Is 'Rejected': '#CD0000' 
    Case Is 'Approved': '#0000EB' 

    CaseElse: 'WhatEver .. 
END SELECT