I am trying to run a select statement that includes multiple if statements when populating a field. Is it possible to put an IF inside a SELECT clause? Here is the code. It says that FROM keyword not found where expected (line 7).
SELECT
m.niin,
d.ddr,
d.d200_mdr,
r.ddr,
r.rbl_mdr,
IF d.d200_mdr>r.rbl_mdr THEN
d.d200_mdr
ELSE IF
r.rbl_mdr>d.d200_mdr THEN
r.rbl_mdr
ELSE IF
r.rbl_mdr=d.d200_mdr THEN
d.d200_mdr
ELSE
'0'
END IF,
IF d.d200_mdr>r.rbl_mdr THEN
'D200A'
ELSE IF
r.rbl_mdr>d.d200_mdr THEN
'RBL'
ELSE
'D200A'
ELSE IF
r.rbl_mdr=d.d200_mdr THEN
'D200A'
ELSE
'USER'
END IF
FROM
RBL_MDR_VIEW r,
D200_MDR_VIEW d
MASTER_NIIN m
WHERE
r.niin=m.niin +
AND d.niin=m.niin +
SELECT
m.niin,
d.ddr,
d.d200_mdr,
r.ddr,
r.rbl_mdr,
IF d.d200_mdr>r.rbl_mdr THEN
d.d200_mdr
ELSE IF
r.rbl_mdr>d.d200_mdr THEN
r.rbl_mdr
ELSE IF
r.rbl_mdr=d.d200_mdr THEN
d.d200_mdr
ELSE
'0'
END IF,
IF d.d200_mdr>r.rbl_mdr THEN
'D200A'
ELSE IF
r.rbl_mdr>d.d200_mdr THEN
'RBL'
ELSE
'D200A'
ELSE IF
r.rbl_mdr=d.d200_mdr THEN
'D200A'
ELSE
'USER'
END IF
FROM
RBL_MDR_VIEW r,
D200_MDR_VIEW d
MASTER_NIIN m
WHERE
r.niin=m.niin +
AND d.niin=m.niin +