Hi,
We have a rule and coefficient for the rule but there is one row that does not work. All filters, and analytics is OK.
Elements of the rule:
Screenshot 1 (Selection)
Screenshot 2 (Scope)
Screenshot 3 (Processing)
Screenshot 4 (Coefficient)
Screenshot 5 (Function)
Function code:
INSERT INTO [FUNCTION_TABLE] ( fncode, fnarg1, fnarg2, fnarg3, fnarg4, fnvalue )
SELECT DISTINCT
[FUNCTION_CODE],
T98.entity,
0,
0,
0,
CASE WHEN (coalesce((select sum(tt.amount) from [WORKTABLE] tt where (tt.ct_0100_mv = 52428881) AND (tt.flow =7) AND (tt.entity = T98.Entity) AND (tt.ct_0100_sl = T98.ct_0100_sl)
AND (tt.accnt = 52428938) AND (tt.ct_0100_ds in (52428816)) AND (tt.nature = 1)),0))=0 OR ((coalesce((select sum(tt.amount) from [WORKTABLE] tt where (tt.ct_0100_mv in (52428800,52428944,52428881)) AND (tt.flow =1) AND (tt.entity = T98.Entity) AND (tt.ct_0100_sl = T98.ct_0100_sl) AND (tt.accnt = 52428938) AND (tt.ct_0100_ds in (52428816)) AND (tt.nature = 1)),0))+ (coalesce((select sum(tt.amount) from [WORKTABLE] tt where (tt.ct_0100_mv = 52428816) AND (tt.flow =6) AND (tt.ct_0100_ai = 52428916) AND (tt.entity = T98.Entity) AND (tt.ct_0100_sl = T98.ct_0100_sl)
AND (tt.accnt = 52428938) AND (tt.ct_0100_ai = 52428916) AND (tt.ct_0100_ds in (52428816)) AND (tt.nature = 1)),0))+(coalesce((select sum(tt.amount) from [WORKTABLE] tt where (tt.ct_0100_mv = 52428836) AND (tt.ct_0100_ai = 52428916) AND (tt.flow =6) AND (tt.entity = T98.Entity) AND (tt.ct_0100_sl = T98.ct_0100_sl)
AND (tt.accnt = 52428938) AND (tt.ct_0100_ds in (52428816)) AND (tt.nature = 1)),0)))=0
THEN
0
ELSE
((coalesce((select sum(tt.consamount) from [WORKTABLE] tt where (tt.flow = 1) AND (tt.entity = T98.Entity) AND (tt.ct_0100_sl = T98.ct_0100_sl) AND
(tt.accnt = 52428938) AND (tt.ct_0100_mv in (52428800,52428944,52428881)) AND (tt.ct_0100_ds = 4) AND (tt.nature in (52428804,52428852))),0)) + (coalesce((select sum(tt.consamount) from [WORKTABLE] tt where (tt.flow = 6) AND (tt.entity = T98.Entity) AND (tt.ct_0100_sl = T98.ct_0100_sl) AND
(tt.accnt = 52428938) AND (tt.ct_0100_mv = 52428816) AND (tt.ct_0100_ai = 52428916) AND (tt.ct_0100_ds = 4) AND (tt.nature = 52428804)),0))+(coalesce((select sum(tt.consamount) from [WORKTABLE] tt where (tt.flow = 6) AND (tt.entity = T98.Entity) AND (tt.ct_0100_sl = T98.ct_0100_sl) AND
(tt.accnt = 52428938) AND (tt.ct_0100_mv = 52428836) AND (tt.ct_0100_ai = 52428916) AND (tt.ct_0100_ds = 4) AND (tt.nature = 52428807)),0))) /
((coalesce((select sum(tt.amount) from [WORKTABLE] tt where (tt.ct_0100_mv in (52428800,52428944,52428881)) AND (tt.flow =1) AND (tt.entity = T98.Entity) AND (tt.ct_0100_sl = T98.ct_0100_sl) AND (tt.accnt = 52428938) AND (tt.ct_0100_ds in (52428816)) AND (tt.nature = 1)),0))+ (coalesce((select sum(tt.amount) from [WORKTABLE] tt where (tt.ct_0100_mv = 52428816) AND (tt.flow =6) AND (tt.ct_0100_ai = 52428916) AND (tt.entity = T98.Entity) AND (tt.ct_0100_sl = T98.ct_0100_sl)
AND (tt.accnt = 52428938) AND (tt.ct_0100_ai = 52428916) AND (tt.ct_0100_ds in (52428816)) AND (tt.nature = 1)),0))+(coalesce((select sum(tt.amount) from [WORKTABLE] tt where (tt.ct_0100_mv = 52428836) AND (tt.ct_0100_ai = 52428916) AND (tt.flow =6) AND (tt.entity = T98.Entity) AND (tt.ct_0100_sl = T98.ct_0100_sl)
AND (tt.accnt = 52428938) AND (tt.ct_0100_ds in (52428816)) AND (tt.nature = 1)),0)))
END
FROM
[WORKTABLE] T98,
CT_ACCOUNT T02
WHERE
T02.name in ('241500')
AND
T98.accnt = T02.id
Shedules:
Screenshot 6 ( Package data)
Screenshot 7 (shudule cons.)
Result of function in PL/SQL Developer:
Screenshot 8 (SQL)
Can you help me please?