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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:57:27+00:00 2026-05-27T12:57:27+00:00

I have a problem that is deceptively difficult! Lets say I have a DB

  • 0

I have a problem that is deceptively difficult! Lets say I have a DB table that looks like this:

student_id  score
502         0
502         2
502         4
407         3
407         1
407         3
50          2
50          4
50          3

What I am trying to achieve is a select statement that will give me this:

502  407   50
0    3     2
2    1     4
4    3     3

So I would be doing something like a select distinct on student_id and set those as column headings. Then I want to list all the scores for each distinct student_id.

  • 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-27T12:57:28+00:00Added an answer on May 27, 2026 at 12:57 pm

    I will put this to rest and say it is not possible to do this in a single sql statement where the statement produces the column headings (in this case student_id) based on what is in the table. It seems you really do need the power of a full programming language to accomplish the task.

    The end goal for me is a CSV so I will create a CSV from the table data and then write a ruby script to read the cells and create a new CSV with the column headings and data.

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

Sidebar

Related Questions

I have a problem that I would like have solved via a SQL query.
I have a problem that seems like its a result of a deadlock-situation. Whe
(I have a problem that I illustrated in this question but had no correct
this is my regex for digital dnumbers: \d+(.\d+)+(,\d+) but now i have problem that
I have a problem that i've struggled with for a long time. This problem
I have this problem that when I setframe of the parent view of the
I have the problem that I like to automagically delete documents in my couch,
I have this problem that my .php file is presented as clear text in
i have this problem that i can't solve for days now...here is my code.
I have a problem that I have not seen addressed in this particular way

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.