Link to home
Start Free TrialLog in
Avatar of Jimbo99999
Jimbo99999Flag for United States of America

asked on

SQL Query Roll-up Rows That Are Inside Rows

Good Day Experts!

I have been tasked with another assignment that I need some help with.  Hopefully you can point me in the right direction.  

I have a list of students that each have 4 classes.  So far we have made it through 3 quarters.  However, the student could have moved here at the start of the second quarter so would only have 2 quarters in the books.  When the class changes, I have to avg the grade percentage for as many quarters as the student was enrolled.  All of the class grade percentages need to be on one line per student.  I have attached a file to try and make it clearer for what I am trying to achieve.  

What is the best way to approach this?

Thank for the help,
jimbo99999
EE.xlsx
Avatar of ste5an
ste5an
Flag of Germany image

Step 1: The averages are a simple GROUP BY query in T-SQL.
Step 2: Depends on your requirements. As you post is tagged VisualBasic.NET, I would do the pivoting in the frond-end.
Avatar of Jimbo99999

ASKER

Hello...thank you for your response.  I have to do this in a SQL Query/Stored Procedure.  

I apologize for the confusion on the VisualBasic.Net category. I was just trying to perhaps get some input from a wider range of experts.

Thanks,
Ed
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for the direction on using Pivot.  I will study it now and implement into my structure.
Thank you for the help.  I was able to get it working!