Project

General

Profile

Feature #1374 » Product_GetBudgetResultCompare_20220621.sql

Tri Rizqiaty, 07/21/2022 02:54 PM

 
1
??ALTER FUNCTION [dbo].[Product_GetBudgetResultCompare] -- SELECT * FROM dbo.GetBudgetResultCompare('100','2011','2010','2009','scriberion','triadblank')
2

3
(	
4

5
	-- Add the parameters for the function here
6

7
	@year VARCHAR(4),
8

9
	@year1 VARCHAR(4),
10

11
    @year2 VARCHAR(4),
12

13
	@scenarioid varchar(20),
14

15
	@CostCenter VARCHAR(20),
16

17
	@EmployeeID VARCHAR(20),
18

19
	@CostObjectType VARCHAR(20)
20

21
)	
22

23
RETURNS TABLE 
24

25
AS
26

27
RETURN 
28

29
(
30

31

32

33
	--DECLARE @year VARCHAR(4) = '2023'
34

35
	--DECLARE @year1 VARCHAR(4) = '2023'
36

37
	--DECLARE @year2 VARCHAR(4) = '2023'
38

39
	--DECLARE @scenarioid varchar(20) = '0000000004'
40

41
	--DECLARE @CostCenter VARCHAR(20) = ''
42

43
	--DECLARE @EmployeeID VARCHAR(20) = ''
44

45
	--DECLARE @CostObjectType VARCHAR(20) = ''
46

47
	
48

49
	-- Add the SELECT statement with parameter references here
50

51
	SELECT @year2 year2, 
52

53
	bud_0.cc_group, bud_0.ce_group,
54

55
	bud_0.CostCenter, bud_0.CostElement,
56

57
	ISNULL(bud_2.amount, 0) amount_2, ISNULL(bud_1.amount, 0) amount_1,
58

59
	bud_0.total_budget,
60

61
	bud_0.amount01,
62

63
	bud_0.amount02,
64

65
	bud_0.amount03,
66

67
	bud_0.amount04,
68

69
	bud_0.amount05,
70

71
	bud_0.amount06,
72

73
	bud_0.amount07,
74

75
	bud_0.amount08,
76

77
	bud_0.amount09,
78

79
	bud_0.amount10,
80

81
	bud_0.amount11,
82

83
	bud_0.amount12
84

85
	FROM dbo.Product_GetBudgetSimulasi(@year, @scenarioid, @CostObjectType, @CostCenter, @EmployeeID) bud_0
86

87
	LEFT OUTER JOIN dbo.Product_GetBudgetActual(@year1, @CostCenter, @EmployeeID) bud_1
88

89
	ON bud_0.CostCenter = bud_1.CostCenter
90

91
	   AND bud_0.CostElement = bud_1.BudgetAcc
92

93
	LEFT OUTER JOIN dbo.Product_GetBudgetActual(@year2, @CostCenter, @EmployeeID) bud_2
94

95
	ON bud_0.CostCenter = bud_2.CostCenter
96

97
	   AND bud_0.CostElement = bud_2.BudgetAcc
98

99
)
100

101

(5-5/10)