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. combine multiple rows in single row

combine multiple rows in single row

Scheduled Pinned Locked Moved Database
tutorial
5 Posts 4 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.
  • I Offline
    I Offline
    i gr8
    wrote on last edited by
    #1

    Hi, I want to combine multiple rows in a single one. Have a look at the following sample. Any body know how to do this....thnx in advance original table ------------------ FID Code Value1 Value2 1 C1 20 Null 1 C1 Null 10 2 C1 30 Null 2 C1 Null 40 To -- FID Code Value1 Value2 1 C1 20 10 2 C1 30 40

    A M 2 Replies Last reply
    0
    • I i gr8

      Hi, I want to combine multiple rows in a single one. Have a look at the following sample. Any body know how to do this....thnx in advance original table ------------------ FID Code Value1 Value2 1 C1 20 Null 1 C1 Null 10 2 C1 30 Null 2 C1 Null 40 To -- FID Code Value1 Value2 1 C1 20 10 2 C1 30 40

      A Offline
      A Offline
      Alegria_Lee
      wrote on last edited by
      #2

      SELECT FID,Code,Max(Value1),Max(Value2)
      FROM TableName
      Group By FID,Code

      B 1 Reply Last reply
      0
      • I i gr8

        Hi, I want to combine multiple rows in a single one. Have a look at the following sample. Any body know how to do this....thnx in advance original table ------------------ FID Code Value1 Value2 1 C1 20 Null 1 C1 Null 10 2 C1 30 Null 2 C1 Null 40 To -- FID Code Value1 Value2 1 C1 20 10 2 C1 30 40

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

        You need a pivot [^] table.

        Never underestimate the power of human stupidity RAH

        1 Reply Last reply
        0
        • A Alegria_Lee

          SELECT FID,Code,Max(Value1),Max(Value2)
          FROM TableName
          Group By FID,Code

          B Offline
          B Offline
          Blue_Boy
          wrote on last edited by
          #4

          Perhaps you should use MIN in any of fields for Value1 or Value2


          I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

          A 1 Reply Last reply
          0
          • B Blue_Boy

            Perhaps you should use MIN in any of fields for Value1 or Value2


            I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

            A Offline
            A Offline
            Alegria_Lee
            wrote on last edited by
            #5

            why MIN?

            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