SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. **Public Class Plan220219_class {**
  2.  
  3. Public Summary1[] Summaries1 {get; set;}
  4. Public Summary2[] Summaries2 {get; set;}
  5. Public Summary3[] Summaries3 {get; set;}
  6.  
  7. Public Plan220219_class() {
  8.  
  9. agg1();
  10.  
  11. agg2();
  12.  
  13. agg3();
  14.  
  15. }
  16.  
  17. public void agg1() {
  18. AggregateResult[] results1 = [SELECT COUNT(OwnerId) CountAcc, Id FROM Account GROUP BY Id];
  19.     Summaries1 = new List<Summary1>();
  20.     FOR(AggregateResult ar1 : results1) {
  21.         Summaries1.add(new Summary1(ar1));
  22.     }
  23. }
  24.  
  25. public void agg2() {
  26. AggregateResult[] results2 = [SELECT COUNT(Id) CountSales, SUM(Sales_amount__c) Sales_amount, contract2__r.contract1__r.account__r.Id FROM Sales__c GROUP BY contract2__r.contract1__r.account__r.Id];
  27.     Summaries2 = new List<Summary2>();
  28.     FOR(AggregateResult ar2 : results2) {
  29.         Summaries2.add(new Summary2(ar2));
  30.     }
  31. }
  32.  
  33. public void agg3() {
  34. AggregateResult[] results3 = [SELECT SUM(Amount) Opp_Amount, Account.Id FROM Opportunity GROUP BY Account.Id];
  35.     Summaries3 = new List<Summary3>();
  36.     FOR(AggregateResult ar3 : results3) {
  37.         Summaries3.add(new Summary3(ar3));
  38.     }
  39. }
  40.  
  41. public class summary1 {
  42.     public Integer CountAcc {get; set;}
  43.     public Id UId {get; set;}        
  44.  
  45. public summary1 (AggregateResult ar1) {
  46.     CountAcc = (Integer) ar1.get('CountAcc');
  47.     UId = (Id) ar1.get('Id');      
  48.     }
  49. }
  50.  
  51. public class summary2 {
  52.     public Integer CountSales {get; set;}
  53.     public Double Sales_Amount {get; set;}      
  54.     public Id UId {get; set;}
  55.  
  56. public summary2 (AggregateResult ar2) {
  57.     CountSales = (Integer) ar2.get('CountSales');
  58.     Sales_Amount = (Double) ar2.get('Sales_amouont');        
  59.     UId = (Id) ar2.get('Id');
  60.     }
  61. }
  62.  
  63. public class summary3 {
  64.     public Double Opp_Amount {get; set;}      
  65.     public Id UId {get; set;}
  66.  
  67. public summary3 (AggregateResult ar3) {
  68.     Opp_Amount = (Double) ar3.get('Opp_Amount');        
  69.     UId = (Id) ar3.get('Id');
  70.     }
  71. }
  72.  
  73. }
  74.  
  75.  
  76. **<apex:page controller="Plan220219_class">**
  77.  
  78. <apex:repeat value="{!Summaries1}" var="summary1">
  79.     {!summary1.UId} : {!summary1.CountAcc} <br/>
  80. </apex:repeat>
  81.  
  82. <br/>
  83.  
  84. <apex:repeat value="{!Summaries2}" var="summary2">
  85.     {!summary2.UId} : {!summary2.CountSales} : {!summary2.Brutto_BWS} <br/>
  86. </apex:repeat>
  87.  
  88. <br/>
  89.  
  90. <apex:repeat value="{!Summaries3}" var="summary3">
  91.     {!summary3.UId} : {!summary3.OPP_Amount} <br/>
  92. </apex:repeat>
  93.  
  94. </apex:page>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top