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. Use column output, to get new column

Use column output, to get new column

Scheduled Pinned Locked Moved Database
databasesql-serversysadminhelp
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.
  • K Offline
    K Offline
    Karan_TN
    wrote on last edited by
    #1

    I am using Sql server 2008. I have 3 columns say, UserID,ManagerID,deptCode. I need the output as UserID,ManagerID,deptCode,ManagersDeptCode So, the column "ManagerID" need to be used to generate the output of "ManagersDeptCode". Please help.

    M 1 Reply Last reply
    0
    • K Karan_TN

      I am using Sql server 2008. I have 3 columns say, UserID,ManagerID,deptCode. I need the output as UserID,ManagerID,deptCode,ManagersDeptCode So, the column "ManagerID" need to be used to generate the output of "ManagersDeptCode". Please help.

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

      Join back to your user table using the managerid ot userid to get the managers details

      Select U.*, M.*
      From UserTable U
      inner join UserTable M on M.userID = U.ManagerID

      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