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
Devaraj 7Devaraj 7 

how to show contact phone numbers with the count in vf page

phone                  count
995566                 2
995566                 2
123456                 1
Maharajan CMaharajan C
Hi Dinesh,

Please try the below codes:

And Click button based on Phone in the Page it will give the result for you:

VF Page:

<apex:page controller="Contactup">
    <apex:form >
        <apex:pageblock title="Duplicate Contacts">
            <apex:pageBlockButtons >
                <apex:commandButton value="based on phone" action="{!getbyphone}"/>
            <apex:PageBlockTable value="{!ac}" var="a"  rendered="{!bLead}">
                <apex:Column value="{!}"/>
                <apex:Column value="{!}"/> 
            <apex:PageBlockTable value="{!ac1}" var="a"  rendered="{!bphone}">
                <apex:Column value="{!a['Phone']}"/>
                <apex:Column value="{!a['count1']}"/> 


public class Contactup {

    public List<Contact>ac{get;set;}
    public List<AggregateResult> ac1 {get; set;}
    public Boolean bphone {get; set;} 
    public Boolean bLead {get; set;}
    public Contactup(){
        bphone = false;
        bLead = true;
        ac =[SELECT name,Phone FROM contact where Phone!=Null];
    public void getbyphone(){
        bphone = true;
        bLead = false;
        ac1=[SELECT Phone,count(Id) count1 FROM lead GROUP BY Phone HAVING count(Id)>=1];

Let me know if it works or not!!!

If it works mark this as a best answer!!!