Hello,
these are the rules you have defined:
The logic is:
i) If we fing Col Type = D in a record put 0
ii) If we get Col Type = M then put 1 for M for that record
iii) If we get a pri_flag=1 along with M we put 1
iv) If we get a net_flag=1 along with M we put 1
v) If we get a pct_flag=1 along with M we put 0
the SQL statement
SELECT m.*,
DECODE(type, 'D', 0, 'M', DECODE(pct_flag, 1, 0, 1)) AS result
FROM mysql m
1) the statement print a 0 when type is D ....
2) the statement print a 1 when type is M ... but you have also defined in
5 that when pct_flag = 1 then print 0 ... the statement does ...
3) pri_flag = 1 and type = M the print a 1 ... this is waste, cause you want to print always a 1 when type = M
(same in 4)
So, where is the mistake ?
Best regards
Manfred Peter
Alligator Company Software GmbH
http://www.alligatorsql.com