question

afroz avatar image
afroz asked

Formatting rows to columns

Hi, Please find below screen for problem statement ![alt text][1] [1]: /storage/temp/1669-sql.png
sqlpivot
sql.png (19.0 KiB)
sql.png (19.0 KiB)
3 comments
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

The result is by subject right ? Which subject's Result do you want to show in the result ?
0 Likes 0 ·
No need of result column in resultant,You can skip that part... I just need all subjects as columns(dynamic) and marks associated to those subjects..
0 Likes 0 ·
Whats wrong with the solution i propose?
0 Likes 0 ·

1 Answer

· Write an Answer
HCRUZ avatar image
HCRUZ answered
Hi, Try this: select * from ( select RollNumber, Subject_name, MarksObtained, result from teste --put here the name of yout table ) t pivot ( sum(MarksObtained) for Subject_name in ([English], [Hindi],[Maths],[RTI],[Science],[Social]) ) p Note: Look at the result column.Change it to see what happens (a P to an F for example).
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.