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. Help combing rows to columns

Help combing rows to columns

Scheduled Pinned Locked Moved Database
databasehelptutorialquestion
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.
  • B Offline
    B Offline
    BrockVnm
    wrote on last edited by
    #1

    I am not sure if this is going to work but figure I mine as well try. I have a query that returns 2 columns and x rows. What I want to do is join simalar rows into the columns but not sure how I can get it done.... Example Id Price 7812 25 7812 34 7813 67 7813 32 What I want to do is have the rows with the same Id show the 2 prices in the same row. Is this at all possible? Thanks for all of your help! :-D


    There are 10 kinds of people in this world. Those who understand binary and those who don't. We shouldn't assume something's debugged just because everyone in the whole world has access to the source code.

    A 1 Reply Last reply
    0
    • B BrockVnm

      I am not sure if this is going to work but figure I mine as well try. I have a query that returns 2 columns and x rows. What I want to do is join simalar rows into the columns but not sure how I can get it done.... Example Id Price 7812 25 7812 34 7813 67 7813 32 What I want to do is have the rows with the same Id show the 2 prices in the same row. Is this at all possible? Thanks for all of your help! :-D


      There are 10 kinds of people in this world. Those who understand binary and those who don't. We shouldn't assume something's debugged just because everyone in the whole world has access to the source code.

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

      Only manually. Add prices as strings with separator ... use hashtable as intermediate Hashtable ht=new Hashtable(1); foreach(DataRow dr in myTable.Rows) if(ht.Contains(dr["id"]) ht[dr["id"]]=ht[dr["id"]].ToString()+","+dr["price"].ToString(); else ht.Add(dr["id"],dr["price"].ToString(); Next, clear DataTable and copy Hashtable into it. Not tested Hi, AW

      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