Welcome to MSSQL Forum!
MSSQL Forum - Discussions about Microsoft SQL Server

You are currently viewing our community forums as a guest user. Sign up or
Having an account grants you additional privileges, such as creating and participating in discussions.

Convert rows to columns query

Discussion in 'General' started by Venkat Rao Konka, Oct 18, 2017.

  1. Venkat Rao Konka

    Venkat Rao Konka New Member

    Hi All,

    Very Good Afternoon.

    i have a requirement of converting a rows to columns and respective data. details are bellow

    i have student subject wise marks with following table structure

    studentexams table structure
    marksid int
    examid int
    subjectid int
    studid bigint
    marks real

    rows are as follows :

    studid subjectid marks
    2 1 90
    2 2 64
    3 1 88
    3 2 95
    4 1 97
    4 2 98

    i need to extract data like as follows

    stuid 1 2 (1 and 2 are subject ids) and subejct ids are in master table
    2 90 64
    3 88 95
    4 97 98

    request to have script to get similar output in this scenario

    Thanks In Advance.

    Regards
    Venkat K
  2. Peter Schmitz

    Peter Schmitz Administrator Staff Member

    Hello Venkat. What have you tried so far?

Share This Page