Cognos CASE声明

时间:2016-03-11 00:46:30

标签: cognos cognos-10

我是Cognos的新手,我正在撰写一份CASE声明并提出两个一般性问题。

  1. 是否有更有效的方式撰写此声明?
  2. 可以将不同的WHEN语句分组到共享共享的位置 描述
  3. 在下面的示例中,几个WHEN条款共享一个共同的结果,即“关键耕作”或“其他作物生产”。

    你能把WHEN声明写成:

    WHEN ('Combo Primary Tillage','Disk Harrows','Field Cultivators') THEN ('Key Tillage') 
    

    代码案例

    CASE([Class Long description])
    WHEN('TR. 20<40') THEN ('Under 40')
    WHEN('TR. 40<60') THEN ('40-59')
    WHEN('TR. 60<100') THEN ('60-99')
    WHEN('TR. 100<140') THEN ('100-139')
    WHEN ('TR. 140<180') THEN ('140+')
    WHEN ('TR. 180+') THEN ('140+')
    WHEN('TR. 4WD') THEN ('4WD')
    WHEN('CMB CAT 5') then ('Combines')
    WHEN('CMB CAT 6') THEN('Combines')
    WHEN('CMB CAT 7') THEN ('Combines')
    WHEN('DISC MC') then ('Major Hay')
    WHEN('SICKLE MC') THEN ('Major Hay')
    WHEN('LARGE SQUARE BALER') THEN ('Major Hay')
    WHEN('SMALL SQUARE BALER') THEN('Major Hay')
    WHEN('ROUND BALER') THEN('Major Hay')
    WHEN('SP WINDROWER') THEN('Major Hay')
    WHEN('BALE THROWER') THEN('Other Hay')
    WHEN('SP SPRAYERS') THEN('Sprayers')
    WHEN('PLANTERS') THEN ('Planters')
    WHEN('COMBO PRIMARY TILLAGE') THEN ('Key Tillage')
    WHEN('DISK HARROWS') THEN('Key Tillage')
    WHEN('FIELD CULTIVATORS') THEN ('Key Tillage')
    WHEN('MIN PRIMARY TILLAGE') THEN('Key Tillage')
    WHEN('VERTICAL SEEDBED TILLAGE') THEN ('Key Tillage')
    WHEN('AIR DRILLS') THEN('Other Crop Production')
    WHEN('FLOATER APPLICATORS') THEN('Other Crop Production')
    WHEN('CHISEL PLOWS') THEN('Other Crop Production')
    WHEN('CRUMBLERS') THEN('Other Crop Production')
    WHEN('PULL TYPE SPRAYERS') THEN('Other Crop Production')
    WHEN('AIR SYSTEMS') THEN('Other Crop Production')
    WHEN('FLOATERS') THEN ('Other Crop Production')
    ELSE ([Class Long description])
    END
    

1 个答案:

答案 0 :(得分:2)

不,不能。您可以像

一样编写它
CASE
WHEN [Class Long description] in ('Combo Primary Tillage','Disk Harrows','Field Cultivators') THEN ('Key Tillage') 
WHEN [Class Long description] in ('AIR SYSTEMS','FLOATERS') THEN ('Other Crop Production') 
.....
END

但你的方法是无效的。您最好为其创建一个表格并将其加入原始表格。