Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7308943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:38:34+00:00 2026-05-28T23:38:34+00:00

We have the following tables: Table 1: Student_Records StudentID     |    CourseID     |

  • 0

We have the following tables:

Table 1: Student_Records
StudentID     |    CourseID     |     Period     |     Grade
   12                       6010                P1                 90

   23                       6020                P1                 80

   12                       6030                P2                 ‘ ‘ Blank, there’s no grade

   15                       6010                P1                 70

   12                       6020                P1                 80

   15                       6020                P1                 90

Table 2: Course_Records
   CourseID        CourseDec       Credits
   6010                   Math                3

   6020                   Biology             3

   6030                   English             3

Table 3: Student_Info
StudentID         FirstName         LastName         ClassYear
12                       Joe                    Smith                2013

15                       Chak                    Li                2013

23                       Pete                    Vo                2013

Result Desire:
ClassYear            LastName            FirstName            StudentId           Math            Biology
2013                      Smith                      Joe                      12                  90                 80
2013                      Li                           Chak                    15                  70                 90

How can I achieve this result using the pivot command?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T23:38:35+00:00Added an answer on May 28, 2026 at 11:38 pm

    You can use PIVOT for this but it requires that you know which course descriptions you’re interested in.

    SELECT p.classyear, 
           p.lastname, 
           p.firstname, 
           p.studentid, 
           pvt.math, 
           pvt.biology 
    FROM   (SELECT sr.grade, 
                   si.classyear, 
                   si.studentid, 
                   si.firstname, 
                   silastname 
            FROM   student_info si 
                   INNER JOIN student_records sr 
                     ON si.studentid = sr.studentid 
                   INNER JOIN course_records cr 
                     ON sr.courseid = cr.courseid) p PIVOT ( AVG (grade) FOR 
           coursedec IN ( 
           [Math], [Biology]) ) AS pvt 
    ORDER  BY pvt.classyear; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following tables CREATE TABLE `files` ( `fileid` int(11) NOT NULL AUTO_INCREMENT,
I have the following tables: CREATE TABLE title ( booktitle VARCHAR( 60 ), title_id
I have the following tables: create table TableA ( Id int primary key identity,
I have the following two tables, affiliates and referrers. affiliates Table id loginid 3
I have two tables with the following (simplified) structures: table "Factors" which holds data
I have a database table that holds the following grade information for a student:
Suppose I have the following two tables: STUDENT studentid lastname firstname 1 Smith John
I have 2 tables with following structures:- 1) Student_Details:- studentId(pk) studentName studentGrade studentExamStatus 2)
I have the following TSQL Select statement select s.StudentID, s.LastName, s.FirstName ,o.CourseID, c.CourseTitle, o.Semester,
I have following two tables (student and marks): In student table I have information

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.