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
SirishaMSirishaM 

Is there a groupby function in SOQL ?

Hi ,

Here is what I am trying to do. I actually have a GRADE table where I have student,course,totalpercentage columns. I also have a detail table named "Marks" which has the "percentage" column obtained in various assignments. This table also has student and course columns. I want to caluculate the sum of percentages based on the student and course. How can I do that ? There is a master-detail relationship between the tables.
So in short-->


Grade- Course,Student, TotalPercentage
Marks-Course,Student,Percentage,Assignment.....(OtherColumns)

So I need sum of percentage grouped by student and course.Kindly help if anybody knows any easy way of doing that.

Thanks in advance
yagnayagna
hi,

Can a student choose more than one course ? If yes, I think you can model your data something like this,

Student (Master) --> Student Name, Total Percentage (Can be roll up summary field)
Course (Detail) --> Course, Grade, Assignment (Assignment can be custom object if you have more than on assignment per course)
Create a report on Student Course and group by Student to get the total percentage of each student.

Hope this helps, or am I way away from suitable solution ??

Regards,
Yagna

SirishaMSirishaM
Hi ,
Thanks for the reply. I did not mention that there are some other objects too . I cud solve the problem by using Apex triggers.
I appreciate for taking time to reply my query.

Sirisha