Question : Case statement within VIEW

Hello,

I need help imbedding a CASE statment within a VIEW. I need to have another field that is a flag based off of the following fields. Is this possible?
    DECODE(fs.stmt_id, NULL, 0, 1) STMT_FLAG,
    DECODE(fr.rule_id, NULL, 0, 1) RULE_FLAG,
    DECODE(fre.entyid, NULL, 0, 1) WORD_FLAG,
    DECODE(fr2.rule_id, NULL, 2, 1) CONT_RULE_FLAG,
    DECODE(FRE2.RULE_ID, NULL, 2, 1) CONT_WRD_FLAG,
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
CREATE OR REPLACE FORCE VIEW V_IN_PROGRESS 
AS
  SELECT DISTINCT P.TTL_TX,
    P.PUBID,
    fs.stmt_id,
    fr.rule_id PRIME_ID,
    fre.entyid WORD,
    fr2.rule_id CONT_RULE_ID,
    FRE2.ENTYID CONT_WRD_ID,
    fs.STMT_TX STMT_TX,
    FR.RULE_TX RULE_TX,
    FR2.RULE_TX CONT_RULE_TX,
    DECODE(fs.stmt_id, NULL, 0, 1) STMT_FLAG,
    DECODE(fr.rule_id, NULL, 0, 1) RULE_FLAG,
    DECODE(fre.entyid, NULL, 0, 1) WORD_FLAG,
    DECODE(fr2.rule_id, NULL, 2, 1) CONT_RULE_FLAG,
    DECODE(FRE2.RULE_ID, NULL, 2, 1) CONT_WRD_FLAG,
    If STMT_FLAG = 1 Then
        '1'
    Else
       '0'
    END If FLAG
  FROM CDB.PUB p,
    CDB.STMT fs,
    CDB.RULE fr,
    CDB.RULE_ENTY FRE,
    CDB.RULE_ASC FASC,
    CDB.RULE fr2,
    CDB.RULE_ENTY FRE2
  WHERE p.pub_id          = fs.pub_id(+)
  AND fs.stmt_id        = fr.stmt_id(+)
  AND fr.rule_id        = FRE.RULE_ID(+)
  AND FASC.O_RULE_ID(+) = fr.rule_id
  AND FASC.S_RULE_ID    = fr2.rule_id(+)
  AND fr2.rule_id       = FRE2.RULE_ID(+)
  AND P.TYP_NM    = 'New Entry'
  ORDER BY PUBID,
    fs.stmt_id,
    fr.rule_id,
    fr2.rule_id,
    fre.entyid;

Answer : Case statement within VIEW

Random Solutions  
 
programming4us programming4us