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. replace the value with different text in Select

replace the value with different text in Select

Scheduled Pinned Locked Moved Database
databasehelptutorial
4 Posts 3 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
    indian143
    wrote on last edited by
    #1

    I have a select statement which joins various tables. But there are two tables which specify nearly same thing but values are different. Because of which when joining its giving more rows than expected. Now I want these two tables to be included in join. like for example QCV_Values table it has Type column as "Oxygen", "NEB" and "Sleep". In another table (arusers) these values are as "HME" and "SLP" in the column "GroupName". "Oxygen" and "NEB" comes under samething "HME". I need to add these tables in to join to avoid duplicacy in the rows. Can any body please help me in achiving this. Except that everything is working fine. Can anybody please help me in that. I am putting my query here And I have to join the Type with the GroupName, but there is no specific table to relate these two.

    SELECT InstanceKey, Category, v.QCDesc, oi.CustCenterName, au.MgrName, oi.InsName1, oi.InsName2,
    oi.InsName3, oi.TherapyId, oi.PhysNum, oi.TherapyIdSlp, oi.PhysNumSlp, SalesPersonName
    FROM dbo.QCV_Instances i
    JOIN dbo.vw_OrderIntake oi ON i.InstanceKey=oi.CustNum
    --JOIN dbo.Center c ON oi.CustCenterId=c.CenterID
    JOIN dbo.arusers au ON oi.CustCenterId=au.CenterID
    JOIN dbo.QCV_Values v ON v.QCID=i.QCValueId

    Thanks & Regards, Md. Abdul Aleem NIIT technologies

    M 1 Reply Last reply
    0
    • I indian143

      I have a select statement which joins various tables. But there are two tables which specify nearly same thing but values are different. Because of which when joining its giving more rows than expected. Now I want these two tables to be included in join. like for example QCV_Values table it has Type column as "Oxygen", "NEB" and "Sleep". In another table (arusers) these values are as "HME" and "SLP" in the column "GroupName". "Oxygen" and "NEB" comes under samething "HME". I need to add these tables in to join to avoid duplicacy in the rows. Can any body please help me in achiving this. Except that everything is working fine. Can anybody please help me in that. I am putting my query here And I have to join the Type with the GroupName, but there is no specific table to relate these two.

      SELECT InstanceKey, Category, v.QCDesc, oi.CustCenterName, au.MgrName, oi.InsName1, oi.InsName2,
      oi.InsName3, oi.TherapyId, oi.PhysNum, oi.TherapyIdSlp, oi.PhysNumSlp, SalesPersonName
      FROM dbo.QCV_Instances i
      JOIN dbo.vw_OrderIntake oi ON i.InstanceKey=oi.CustNum
      --JOIN dbo.Center c ON oi.CustCenterId=c.CenterID
      JOIN dbo.arusers au ON oi.CustCenterId=au.CenterID
      JOIN dbo.QCV_Values v ON v.QCID=i.QCValueId

      Thanks & Regards, Md. Abdul Aleem NIIT technologies

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

      You have a serious problem, it's called crappy data! You either create a CASE in the join that maps each type to another or you create a mapping table that does the same thing. There are pros and cons for both solutions. CASE needs a change to a procedure if there is a new mapping, map table needs maintenance.

      Never underestimate the power of human stupidity RAH

      I C 2 Replies Last reply
      0
      • M Mycroft Holmes

        You have a serious problem, it's called crappy data! You either create a CASE in the join that maps each type to another or you create a mapping table that does the same thing. There are pros and cons for both solutions. CASE needs a change to a procedure if there is a new mapping, map table needs maintenance.

        Never underestimate the power of human stupidity RAH

        C Offline
        C Offline
        CitrusTech
        wrote on last edited by
        #3

        I concur. But how many times have we all see stuff like this? I like your mapping table solution, unless this is a one off exercise in which case a case statement will run faster and won't need to be maintained.

        Data Quality Solutions

        1 Reply Last reply
        0
        • M Mycroft Holmes

          You have a serious problem, it's called crappy data! You either create a CASE in the join that maps each type to another or you create a mapping table that does the same thing. There are pros and cons for both solutions. CASE needs a change to a procedure if there is a new mapping, map table needs maintenance.

          Never underestimate the power of human stupidity RAH

          I Offline
          I Offline
          indian143
          wrote on last edited by
          #4

          Hi, Yes, I have done it. As my office is far from my house I couldnt inform the same. But your reply is very usefull. Thanks a lot buddy.

          Thanks & Regards, Md. Abdul Aleem NIIT technologies

          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