• Anoop Kumar 31
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 2
    Replies
public class Program1 
{
    public void print()
    {
         integer i, j;
            for (i = 1; i <= 5; i++)
            {
                for (j = 1; j <= i; j++)
                {
                    system.debug(i);
                }
                 
            }
    }
}

i am getting output but not in this shape User-added image
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5 
 
<apex:page standardController="Account" >
    <apex:form >
        <apex:pageBlock title="Show Attached Contacts">
            <apex:pageBlockSection title="Files" >
             <apex:inputField  value="{!Account.Name}" /> 
              <apex:inputField value="{!Account.Industry}"/> </apex:pageBlockSection>
                             
                <apex:pageBlockButtons location="Bottom">
                    <apex:commandButton value="Click Me!"  />           
                </apex:pageBlockButtons>
            </apex:pageBlock>
    </apex:form>
</apex:page>
I have tried this :
trigger Surajtrg on Contact (after insert, after update, after delete)
{
    set<id> act=new set<id>();
    List <Account> lstAccountsToUpdate = new List <Account>();
    if(trigger.isInsert ||trigger.isUpdate)
    {
        for(contact cc:trigger.new)
        {
            act.add(cc.AccountId);
         }
    }
    if(trigger.isDelete)
    {
        for(contact cc:trigger.old)
        {
            act.add(cc.AccountId);
        }
    }
    List<Account> shocksList = [SELECT Id,Youngest__c,(SELECT id,MIN(Age__c) FROM Contact) from Account where Id IN: act]; 
for(Account acc:shocksList) //(Select Id from Contacts)  represents size of Contacts        
{
    Account accObj = new Account ();
    accObj.Id = acc.Id;
   accObj.Youngest__c= acc.MIN(Age__c);
    lstAccountsToUpdate.add(accObj);
}
    Update lstAccountsToUpdate; 
}
 
I have multiple contacts with their different ages. I want to fetch out minimum and max age among all contacts. 
I tried this query....Select id,Min(age__c) from Contact GROUP BY Name.
please correct me
I have multiple contacts with their different ages. I want to fetch out minimum and max age among all contacts. 
I tried this query....Select id,Min(age__c) from Contact GROUP BY Name.
please correct me