1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
| SELECT EL1, EL2, EL3, SUM(ENGAGE) AS ENGAGE, SUM(BUDGET) AS BUDGET, SUM(REEL) AS REEL, sum(BUDGET-REEL-ENGAGE) as DISPO, sum((BUDGET-REEL-ENGAGE)/BUDGET) as POURCENTAGEDISPO
FROM
(
SELECT
el1 AS EL1,
el2 AS EL2,
el3 AS EL3,
0 AS ENGAGE,
SUM(full_value) AS BUDGET,
0 AS REEL,
0 as DISPO,
0 as POURCENTAGEDISPO
FROM
dbo.oas_balance
WHERE (cmpcode = 'SOC-A') AND (yr = '2009') AND (balcode = 'BUD-INITIAL') AND (repbasis = 7)
GROUP BY el1, el2, el3
UNION
SELECT
el1 AS EL1,
el2 AS EL2,
el3 AS EL3,
0 AS ENGAGE,
0 AS BUDGET,
SUM(full_value) AS REEL,
0 as DISPO,
0 as POURCENTAGEDISPO
FROM
dbo.oas_balance AS oas_balance_2
WHERE (cmpcode = 'SOC-A') AND (yr = '2009') AND (balcode = 'REEL') AND (repbasis = 7)
GROUP BY el1, el2, el3
UNION
SELECT
el1 AS EL1,
el2 AS EL2,
el3 AS EL3,
SUM(full_value) AS ENGAGE,
0 AS BUDGET,
0 AS REEL,
0 as DISPO,
0 as POURCENTAGEDISPO
FROM
dbo.oas_balance AS oas_balance_1
WHERE (cmpcode = 'SOC-A') AND (yr = '2009') AND (balcode = 'ENGAGEMENT') AND (repbasis = 7)
GROUP BY el1, el2, el3) AS x
GROUP BY EL1, EL2, EL3
ORDER BY EL3, EL1, EL2SELECT
EL1,
EL2,
EL3,
SUM(ENGAGE) AS ENGAGE,
SUM(BUDGET) AS BUDGET,
SUM(REEL) AS REEL,
sum(BUDGET-REEL-ENGAGE) as DISPO,
sum((BUDGET-REEL-ENGAGE)/BUDGET) as POURCENTAGEDISPO
FROM
(
SELECT
el1 AS EL1,
el2 AS EL2,
el3 AS EL3,
0 AS ENGAGE,
SUM(full_value) AS BUDGET,
0 AS REEL,
0 as DISPO,
0 as POURCENTAGEDISPO
FROM
dbo.oas_balance
WHERE (cmpcode = 'SOC-A') AND (yr = '2009') AND (balcode = 'BUD-INITIAL') AND (repbasis = 7)
GROUP BY el1, el2, el3
UNION
SELECT
el1 AS EL1,
el2 AS EL2,
el3 AS EL3,
0 AS ENGAGE,
0 AS BUDGET,
SUM(full_value) AS REEL,
0 as DISPO,
0 as POURCENTAGEDISPO
FROM
dbo.oas_balance AS oas_balance_2
WHERE (cmpcode = 'SOC-A') AND (yr = '2009') AND (balcode = 'REEL') AND (repbasis = 7)
GROUP BY el1, el2, el3
UNION
SELECT
el1 AS EL1,
el2 AS EL2,
el3 AS EL3,
SUM(full_value) AS ENGAGE,
0 AS BUDGET,
0 AS REEL,
0 as DISPO,
0 as POURCENTAGEDISPO
FROM
dbo.oas_balance AS oas_balance_1
WHERE (cmpcode = 'SOC-A') AND (yr = '2009') AND (balcode = 'ENGAGEMENT') AND (repbasis = 7)
GROUP BY el1, el2, el3) AS x
GROUP BY EL1, EL2, EL3
ORDER BY EL3, EL1, EL2
|
Partager