function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Yogesh BiyaniYogesh Biyani 

VF how to : instead of Account Id associated with the Opportunity show the Account Name

I am trying to the queries from this link into a visualforce page. Here is the controller class 
// https://salesforce.stackexchange.com/questions/118109/how-to-use-custom-date-fields-in-visualforce-page
// 
public with sharing class DisplayDriftInfluncedOpportunity{
    public static Date startDate{get;set;}
    public static Date endDate{get;set;}
    //public static List<Account> accList{get;set;}
    public boolean showResult{get;set;}
    public boolean blnNoResultFound{get;set;}
    public List<SObject> Records {get; set;}
    
    public DisplayDriftInfluncedOpportunity(){
        showResult = false;
        blnNoResultFound = false;
        Records = new List<SObject>();
        endDate=date.today();
        startDate=endDate-90;
    }
    
    
    public void searchResults(){
        List<Task> accs= [select Id, AccountId
                          from Task
                          where
                          Subject = 'Conversation in Drift' and
                          AccountId != null and
                          AccountId in (
                              Select AccountId
                              from Opportunity
                              WHERE 
                              //Calendar_Year(CreatedDate)=2018
                              DAY_ONLY(CreatedDate) >= :startDate and
                              DAY_ONLY(CreatedDate) <= :endDate
                          )]
            ;
        
        Set<Id> acca1 = new Set<Id>();
        for(Task t :accs)
            acca1.add(t.AccountId);
        
        List<SObject> r=[select AccountId accId, COUNT(Name) oCount , SUM(Amount) Total , DAY_ONLY(CreatedDate) CreatedDate  , CloseDate 
                         from Opportunity
                         where
                        // Calendar_Year(CreatedDate)=2018 and
                         DAY_ONLY(CreatedDate) >= :startDate and
                         DAY_ONLY(CreatedDate) <= :endDate and
                         AccountId in :acca1
                         group by DAY_ONLY(CreatedDate), AccountId, CloseDate];
        
        Records =r;
        
    }
}

And the corresponding visualforce page .
 
<apex:page controller="DisplayDriftInfluncedOpportunity" docType="html-5.0">
    
<center><h1>Opportunity Search Page</h1></center>
<apex:form >
   Start Date: <apex:input type="date" value="{!startDate}" required="true" />
   End Date: <apex:input type="date" value="{!endDate}" required="true" /> 
    <apex:commandButton action="{!searchResults}" value="Search" />
</apex:form> 
<apex:pageBlock title="Opportunities Influenced by Drift">
  <apex:pageBlockTable value="{!Records}" var="Record">
   <apex:column >
    <apex:facet name="header">Account id</apex:facet>
    <apex:outputlink value="/{!Record['accId']}">{!Record['accId']}</apex:outputlink>
   </apex:column>
   <apex:column >
    <apex:facet name="header">Count</apex:facet>
       <apex:outputText value="{!Record['oCount']}"/>
   </apex:column>
   <apex:column >
    <apex:facet name="header">Total</apex:facet>
       <apex:outputText value="{!Record['Total']}"/>
   </apex:column>
      
   <apex:column >
    <apex:facet name="header">CreatedDate</apex:facet>
       <apex:outputText value="{!Record['CreatedDate']}"/>
   </apex:column>
   <apex:column >
    <apex:facet name="header">CloseDate</apex:facet>
       <apex:outputText value="{!Record['CloseDate']}"/>
   </apex:column>
  </apex:pageBlockTable>
</apex:pageBlock>
    
</apex:page>
 Instead of Account Id associated with the Opportunity, I would like to show the Account Name. What do I need to change?

Yogesh
Steven NsubugaSteven Nsubuga
// https://salesforce.stackexchange.com/questions/118109/how-to-use-custom-date-fields-in-visualforce-page
// 
public with sharing class DisplayDriftInfluncedOpportunity{
    public static Date startDate{get;set;}
    public static Date endDate{get;set;}
    //public static List<Account> accList{get;set;}
    public boolean showResult{get;set;}
    public boolean blnNoResultFound{get;set;}
    public List<SObject> Records {get; set;}
    
    public DisplayDriftInfluncedOpportunity(){
        showResult = false;
        blnNoResultFound = false;
        Records = new List<SObject>();
        endDate=date.today();
        startDate=endDate-90;
    }
    
    
    public void searchResults(){
        List<Task> accs= [select Id, AccountId
                          from Task
                          where
                          Subject = 'Conversation in Drift' and
                          AccountId != null and
                          AccountId in (
                              Select AccountId
                              from Opportunity
                              WHERE 
                              //Calendar_Year(CreatedDate)=2018
                              DAY_ONLY(CreatedDate) >= :startDate and
                              DAY_ONLY(CreatedDate) <= :endDate
                          )]
            ;
        
        Set<Id> acca1 = new Set<Id>();
        for(Task t :accs)
            acca1.add(t.AccountId);
        
        List<SObject> r=[select AccountId accId, Account.Name accName,  COUNT(Name) oCount , SUM(Amount) Total , DAY_ONLY(CreatedDate) CreatedDate  , CloseDate 
                         from Opportunity
                         where
                        // Calendar_Year(CreatedDate)=2018 and
                         DAY_ONLY(CreatedDate) >= :startDate and
                         DAY_ONLY(CreatedDate) <= :endDate and
                         AccountId in :acca1
                         group by DAY_ONLY(CreatedDate), AccountId, CloseDate, Account.Name];
        
        Records =r;
        
    }
}
<apex:page controller="DisplayDriftInfluncedOpportunity" docType="html-5.0">
    
<center><h1>Opportunity Search Page</h1></center>
<apex:form >
   Start Date: <apex:input type="date" value="{!startDate}" required="true" />
   End Date: <apex:input type="date" value="{!endDate}" required="true" /> 
    <apex:commandButton action="{!searchResults}" value="Search" />
</apex:form> 
<apex:pageBlock title="Opportunities Influenced by Drift">
  <apex:pageBlockTable value="{!Records}" var="Record">
   <apex:column >
    <apex:facet name="header">Account id</apex:facet>
    <apex:outputlink value="/{!Record['accId']}">{!Record['accName']}</apex:outputlink>
   </apex:column>
   <apex:column >
    <apex:facet name="header">Count</apex:facet>
       <apex:outputText value="{!Record['oCount']}"/>
   </apex:column>
   <apex:column >
    <apex:facet name="header">Total</apex:facet>
       <apex:outputText value="{!Record['Total']}"/>
   </apex:column>
      
   <apex:column >
    <apex:facet name="header">CreatedDate</apex:facet>
       <apex:outputText value="{!Record['CreatedDate']}"/>
   </apex:column>
   <apex:column >
    <apex:facet name="header">CloseDate</apex:facet>
       <apex:outputText value="{!Record['CloseDate']}"/>
   </apex:column>
  </apex:pageBlockTable>
</apex:pageBlock>
    
</apex:page>


 
Yogesh BiyaniYogesh Biyani
@Steven, Thank you. It worked! 
Steven NsubugaSteven Nsubuga
Great @Yogesh!!
Please mark my response as a best answer to resolve the question.