Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Convert row to columns in SQL View or Procedure

Convert row to columns in SQL View or Procedure

Scheduled Pinned Locked Moved Database
databasehelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 11119933
    wrote on last edited by
    #1

    I have table looks like below.

    EMPID QID QDesc Reason Sub Reason Remarks
    201 1 Question 1 Reason1 Break Taking break
    201 2 Question 2 Reason2 Poor
    201 2 Question 2 Reason3 Good
    201 2 Question 2 Reason4 Average
    201 2 Question 2 Reason5 Good
    201 2 Question 2 Reason6 Average
    201 2 Question 2 Reason7 Average
    201 2 Question 2 Reason8 Average
    201 3 Question 3 NA
    201 4 Question 4 Reason9
    201 5 Question 5 Reason10 Yes

    Required Output from the above table should be in the below format. Please help.

    Emp ID Question 1 Question 2 Question 3 Question 4 Question 5 Remarks
    Reason Sub reason Remarks Reason2 Reason3 to Reason8

    M 1 Reply Last reply
    0
    • U User 11119933

      I have table looks like below.

      EMPID QID QDesc Reason Sub Reason Remarks
      201 1 Question 1 Reason1 Break Taking break
      201 2 Question 2 Reason2 Poor
      201 2 Question 2 Reason3 Good
      201 2 Question 2 Reason4 Average
      201 2 Question 2 Reason5 Good
      201 2 Question 2 Reason6 Average
      201 2 Question 2 Reason7 Average
      201 2 Question 2 Reason8 Average
      201 3 Question 3 NA
      201 4 Question 4 Reason9
      201 5 Question 5 Reason10 Yes

      Required Output from the above table should be in the below format. Please help.

      Emp ID Question 1 Question 2 Question 3 Question 4 Question 5 Remarks
      Reason Sub reason Remarks Reason2 Reason3 to Reason8

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      This article [^]might help you! You are looking at a PIVOT table.

      Never underestimate the power of human stupidity RAH

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups