Project

General

Profile

Bug #1203 » Product_GetBudgetResultCompare_20220621.sql

Tri Rizqiaty, 06/29/2022 10:00 AM

 
1
??USE [MinovaES_Bank_Kalteng_Dev]
2

3
GO
4

5
/****** Object:  UserDefinedFunction [dbo].[Product_GetBudgetResultCompare]    Script Date: 21/06/2022 10.17.14 ******/
6

7
SET ANSI_NULLS ON
8

9
GO
10

11
SET QUOTED_IDENTIFIER ON
12

13
GO
14

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

17
(	
18

19
	-- Add the parameters for the function here
20

21
	@year VARCHAR(4),
22

23
	@year1 VARCHAR(4),
24

25
    @year2 VARCHAR(4),
26

27
	@scenarioid varchar(20),
28

29
	@CostCenter VARCHAR(20),
30

31
	@EmployeeID VARCHAR(20),
32

33
	@CostObjectType VARCHAR(20)
34

35
)	
36

37
RETURNS TABLE 
38

39
AS
40

41
RETURN 
42

43
(
44

45

46

47
	--DECLARE @year VARCHAR(4) = '2023'
48

49
	--DECLARE @year1 VARCHAR(4) = '2023'
50

51
	--DECLARE @year2 VARCHAR(4) = '2023'
52

53
	--DECLARE @scenarioid varchar(20) = '0000000004'
54

55
	--DECLARE @CostCenter VARCHAR(20) = ''
56

57
	--DECLARE @EmployeeID VARCHAR(20) = ''
58

59
	--DECLARE @CostObjectType VARCHAR(20) = ''
60

61
	
62

63
	-- Add the SELECT statement with parameter references here
64

65
	SELECT @year2 year2, 
66

67
	bud_0.cc_group, bud_0.ce_group,
68

69
	bud_0.CostCenter, bud_0.CostElement,
70

71
	ISNULL(bud_2.amount, 0) amount_2, ISNULL(bud_1.amount, 0) amount_1,
72

73
	bud_0.total_budget,
74

75
	bud_0.amount01,
76

77
	bud_0.amount02,
78

79
	bud_0.amount03,
80

81
	bud_0.amount04,
82

83
	bud_0.amount05,
84

85
	bud_0.amount06,
86

87
	bud_0.amount07,
88

89
	bud_0.amount08,
90

91
	bud_0.amount09,
92

93
	bud_0.amount10,
94

95
	bud_0.amount11,
96

97
	bud_0.amount12
98

99
	FROM dbo.Product_GetBudgetSimulasi(@year, @scenarioid, @CostObjectType, @CostCenter, @EmployeeID) bud_0
100

101
	LEFT OUTER JOIN dbo.Product_GetBudgetActual(@year1, @CostCenter, @EmployeeID) bud_1
102

103
	ON bud_0.CostCenter = bud_1.CostCenter
104

105
	   AND bud_0.CostElement = bud_1.BudgetAcc
106

107
	LEFT OUTER JOIN dbo.Product_GetBudgetActual(@year2, @CostCenter, @EmployeeID) bud_2
108

109
	ON bud_0.CostCenter = bud_2.CostCenter
110

111
	   AND bud_0.CostElement = bud_2.BudgetAcc
112

113
)
114

115

(9-9/21)