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

  • Home
  • SEARCH
  • 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 7726321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:11:04+00:00 2026-06-01T05:11:04+00:00

I need to select multiple table and one of it is transposed, my table

  • 0

I need to select multiple table and one of it is transposed, my table is listed below:
table_score

|ID  | Subject | Score|
----------------------
|001 | 2GSLIG  | 80   |
|001 | 3ECITI  | 70   |
|002 | 2GSLIG  | 75   |
|002 | 3ECITI  | 85   |
-----------------------

table_student

|ID  | StudentName |
--------------------
|001 | Diana       |
|002 | Yose        |
--------------------

then I want to make it into

|ID |StudentName| 2GSLIG | 3ECITI |
-----------------------------------
|001| Diana     |  80   |   70   |
|002| Yose      |  85   |   75   |
----------------------------------

this is my code so far but I encounter error

SELECT (
    ID,
    SUM(IF(Subject = '2GSLIG', Score, 0)) AS `2GSLIG`,
    SUM(IF(Subject = '3ECITI', Score, 0)) AS `3ECITI`
FROM table_score) JOIN (SELECT StudentName from table_student)
GROUP BY ID

I wonder if someone would help me, thank you

  • 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-06-01T05:11:05+00:00Added an answer on June 1, 2026 at 5:11 am
    SELECT tsc.ID,
           tst.StudentName,
           SUM(CASE WHEN tsc.Subject='2GSLIG' THEN tsc.Score END) AS '2GSLIG',
           SUM(CASE WHEN tsc.Subject='3ECITI' THEN tsc.Score END) AS '3ECITI'
    FROM table_score tsc
    INNER JOIN
    table_student tst 
    ON tsc.ID = tst.ID
    GROUP BY tsc.ID,tst.StudentName;   
    

    Check this on SQLFIDDLE – http://sqlfiddle.com/#!3/68e96/1

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

Sidebar

Related Questions

I have multiple tables that need to be merged into one. SELECT name, SUM(money)
I need to select multiple records I use SELECT * FROM `table` WHERE `ID`
I need to know of a way to combine multiple SELECT statements in one
Ok, so basically I need to select multiple IDs from one column, then use
I am trying to update multiple rows in one table, based on a select
I need to be able to select multiple options on a web form, but
I need to select a bunch of data into a temp table to then
I need a select from table which does not have column that tells when
I need to select a datetime column in a table. However, I want the
I have a multiple select element, I need searching in the database with all

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.