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. converting column values to column. [modified]

converting column values to column. [modified]

Scheduled Pinned Locked Moved Database
databasehelp
6 Posts 6 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.
  • L Offline
    L Offline
    livewire13
    wrote on last edited by
    #1

    Table-A is having 4 columns. I want to select values from Table-A with values from Event columns as column names as shown in Table-B. I need a stored procedure for selecting it if its possible. TABLE-A ID.No--Name-----Event-----------Amount_Paid 1---- Terry---ReliefFund------100 1---- Terry---Donation--------200 2---- John----Festival--------100 2---- John----Donation--------300 TABLE-B ID.No---Name----ReliefFund------Donation--------Festival 1-------Terry---100-------------200-------------0 2-------John----0---------------300-------------100 Please help..., thanks

    modified on Saturday, December 11, 2010 12:45 AM

    K T G M R 5 Replies Last reply
    0
    • L livewire13

      Table-A is having 4 columns. I want to select values from Table-A with values from Event columns as column names as shown in Table-B. I need a stored procedure for selecting it if its possible. TABLE-A ID.No--Name-----Event-----------Amount_Paid 1---- Terry---ReliefFund------100 1---- Terry---Donation--------200 2---- John----Festival--------100 2---- John----Donation--------300 TABLE-B ID.No---Name----ReliefFund------Donation--------Festival 1-------Terry---100-------------200-------------0 2-------John----0---------------300-------------100 Please help..., thanks

      modified on Saturday, December 11, 2010 12:45 AM

      K Offline
      K Offline
      Kasson
      wrote on last edited by
      #2

      For this what query you have developed? What error it shows?

      With Regards, Kasson

      1 Reply Last reply
      0
      • L livewire13

        Table-A is having 4 columns. I want to select values from Table-A with values from Event columns as column names as shown in Table-B. I need a stored procedure for selecting it if its possible. TABLE-A ID.No--Name-----Event-----------Amount_Paid 1---- Terry---ReliefFund------100 1---- Terry---Donation--------200 2---- John----Festival--------100 2---- John----Donation--------300 TABLE-B ID.No---Name----ReliefFund------Donation--------Festival 1-------Terry---100-------------200-------------0 2-------John----0---------------300-------------100 Please help..., thanks

        modified on Saturday, December 11, 2010 12:45 AM

        T Offline
        T Offline
        thatraja
        wrote on last edited by
        #3

        Use PIVOT and UNPIVOT[^]

        thatraja |Chennai|India|


        Brainbench certifications
        Univotes are like kid's kisses don't reject it :-)
        Do what you want quickly because the Doomsday on 2012 :-)
        My childhood story

        1 Reply Last reply
        0
        • L livewire13

          Table-A is having 4 columns. I want to select values from Table-A with values from Event columns as column names as shown in Table-B. I need a stored procedure for selecting it if its possible. TABLE-A ID.No--Name-----Event-----------Amount_Paid 1---- Terry---ReliefFund------100 1---- Terry---Donation--------200 2---- John----Festival--------100 2---- John----Donation--------300 TABLE-B ID.No---Name----ReliefFund------Donation--------Festival 1-------Terry---100-------------200-------------0 2-------John----0---------------300-------------100 Please help..., thanks

          modified on Saturday, December 11, 2010 12:45 AM

          G Offline
          G Offline
          Goutam Patra
          wrote on last edited by
          #4

          SELECT * FROM mytable AS A
          PIVOT (
          SUM(AMOUNT)
          FOR MEVENT IN([ReliefFund], [Donation], [Festival])
          ) AS M

          1 Reply Last reply
          0
          • L livewire13

            Table-A is having 4 columns. I want to select values from Table-A with values from Event columns as column names as shown in Table-B. I need a stored procedure for selecting it if its possible. TABLE-A ID.No--Name-----Event-----------Amount_Paid 1---- Terry---ReliefFund------100 1---- Terry---Donation--------200 2---- John----Festival--------100 2---- John----Donation--------300 TABLE-B ID.No---Name----ReliefFund------Donation--------Festival 1-------Terry---100-------------200-------------0 2-------John----0---------------300-------------100 Please help..., thanks

            modified on Saturday, December 11, 2010 12:45 AM

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

            This article [^]may be of use to you

            Never underestimate the power of human stupidity RAH

            1 Reply Last reply
            0
            • L livewire13

              Table-A is having 4 columns. I want to select values from Table-A with values from Event columns as column names as shown in Table-B. I need a stored procedure for selecting it if its possible. TABLE-A ID.No--Name-----Event-----------Amount_Paid 1---- Terry---ReliefFund------100 1---- Terry---Donation--------200 2---- John----Festival--------100 2---- John----Donation--------300 TABLE-B ID.No---Name----ReliefFund------Donation--------Festival 1-------Terry---100-------------200-------------0 2-------John----0---------------300-------------100 Please help..., thanks

              modified on Saturday, December 11, 2010 12:45 AM

              R Offline
              R Offline
              RaviRanjanKr
              wrote on last edited by
              #6

              This Link[^] may help you.

              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