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 64569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:48:37+00:00 2026-05-10T18:48:37+00:00

I am working with a set of data that looks something like the following.

  • 0

I am working with a set of data that looks something like the following.

StudentName  | AssignmentName |  Grade --------------------------------------- StudentA     | Assignment 1   | 100 StudentA     | Assignment 2   | 80 StudentA     | Total          | 180 StudentB     | Assignment 1   | 100 StudentB     | Assignment 2   | 80 StudentB     | Assignment 3   | 100 StudentB     | Total          | 280 

The name and number of assignments are dynamic, I need to get results simlilar to the following.

Student      | Assignment 1  | Assignment 2  | Assignment 3  | Total -------------------------------------------------------------------- Student A    | 100           | 80            | null          | 180 Student B    | 100           | 80            | 100           | 280 

Now ideally I would like to sort the column based on a ‘due date’ that could be included/associated with each assignment. The total should be at the end if possible (It can be calculated and removed from the query if possible.)

I know how to do it for the 3 assignments using pivot with simply naming the columns, it is trying to do it in a dynamic fashion that I haven’t found a GOOD solution for yet. I am trying to do this on SQL Server 2005

EDIT

Ideally I would like to implement this WITHOUT using Dynamic SQL, as that is against the policy. If it isn’t possible…then a working example with Dynamic SQL will work.

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-10T18:48:38+00:00Added an answer on May 10, 2026 at 6:48 pm

    I know you said no dynamic SQL, but I don’t see any way to do it in straight SQL.

    If you check out my answers to similar problems at Pivot Table and Concatenate Columns and PIVOT in sql 2005

    The dynamic SQL there is not vulnerable to injection, and there is no good reason to prohibit it. Another possibility (if the data is changing very infrequently) is to do code-generation – instead of dynamic SQL, the SQL is generated to a stored procedure on a regular basis.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have data in a table that looks like the following sample data: varchar(20)
I have a large data set that I'm working with in excel. About 1000+
I have a working program in C++ that generates data for a Mandelbrot Set.
I'm working on a .NET component that gets a set of data from the
I have a base Color class that looks something like this. The class is
I'm working on a webapp that uses jQuery, and I'm getting something that looks
I'm working with about a 1 million record data set. Currently the data is
I was wondering... when working with a fixed set of data (say: the population
I am working with a set of T4 script that generate partial classes for
So here's something I find puzzling. I'm working on a Javascript that needs to

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.