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
lakshman.mattilakshman.matti 

VF page

i have a student object.there are columns like name and marks.there are 10 records with different marks.

now i want to build a custom VF Page which outputs like below

Grade column     count

-------------------------------

 

A' Grade               5

B' Grade               3

 

 

i hope i'm clearly conveyed my requirement.can some body guide me how to achieve this..

 

Regards

Lakshman

 

SSinghSSingh

You can use Group BY clause in SOQL to get the desired result and then it would be easy to render the data on VF page.

 

SS

JogendraJogendra
Hi Lakshman



You can achieve your requirement by getting count of student records by grouping them by Marks.



Sample Soql : [SELECT Grade__c, Count(Id) FROM Student_Grades__c GROUP BY Grade__c]



After this , Loop over the aggregate result and add the results using a wrapper class into a list and display the list in the visual force page.



For reference please refer the link : http://stackoverflow.com/questions/8523303/how-do-i-display-the-results-of-an-aggregate-soql-query-on-a-visualforce-page



Please let me know if this helped you or not.



Regards
Jogendra
lakshman.mattilakshman.matti

how to devide it into 3 grades..group by will categorize into distinct groups it will not  divide result into 3 groups..

lakshman.mattilakshman.matti

grade is not a filed here...we need to explicitly categorise them into grades based marks ranges(ex: if marks are  between 70-100 then grade A,50-70 grade B,40-50 grade C like this..)

JogendraJogendra
In might be a long approach

1.Create grade as a picklist with values as 'A','B','C' and 'Fail'.

2. Create 3 workflow rules respectively on students object with condition as ex: IF( CEILING( Marks__c )>40 && CEILING( Marks__c )<=50,true,false )

3. Create field updates on the grade field based on the above conditions.

4. Later follow the steps as specified by me in the above post for creating the VF page and class.

Please let me know if this has helped or not.

Thanks
Jogendra