Skip to main content
Tweeted twitter.com/#!/StackDBAs/status/115862541812510720
added 40 characters in body
Source Link
Cell-o
  • 1.1k
  • 8
  • 21
  • 40

I have a table as shown below.My question is:How can I convert columns into rows?BTW,I'm using Microsoft SQL Server 2005.

my input Data

  ONAY_ID  sip_RECno    KULLANICI       ONAY
   1           1         user1          true
   2           1         user2          true
   3           1         user3          false
   4           1         user4          true

Output would be

 sip_RECno  user1     user2    user3     user4       

  1          true     true    false    true          

I have a table as shown below.My question is:How can I convert columns into rows?

my input Data

  ONAY_ID  sip_RECno    KULLANICI       ONAY
   1           1         user1          true
   2           1         user2          true
   3           1         user3          false
   4           1         user4          true

Output would be

 sip_RECno  user1     user2    user3     user4       

  1          true     true    false    true          

I have a table as shown below.My question is:How can I convert columns into rows?BTW,I'm using Microsoft SQL Server 2005.

my input Data

  ONAY_ID  sip_RECno    KULLANICI       ONAY
   1           1         user1          true
   2           1         user2          true
   3           1         user3          false
   4           1         user4          true

Output would be

 sip_RECno  user1     user2    user3     user4       

  1          true     true    false    true          
edited tags
Link
Aaron Bertrand
  • 181.5k
  • 28
  • 402
  • 619
Source Link
Cell-o
  • 1.1k
  • 8
  • 21
  • 40

SQL query to convert columns into rows

I have a table as shown below.My question is:How can I convert columns into rows?

my input Data

  ONAY_ID  sip_RECno    KULLANICI       ONAY
   1           1         user1          true
   2           1         user2          true
   3           1         user3          false
   4           1         user4          true

Output would be

 sip_RECno  user1     user2    user3     user4       

  1          true     true    false    true