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. Query Help

Query Help

Scheduled Pinned Locked Moved Database
databasehelpxmltutorial
4 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.
  • H Offline
    H Offline
    Hulicat
    wrote on last edited by
    #1

    Hello, I have the following query working well, however; I need to augment it and what seemed simple has really stumoed me. Maybe some of you can guide me in the right direction. use db1 select distinct v.userid, v.firstname, v.lastname, c.[name] as 'credential field', q.address, value from import3 inner join vulture v on v.userid = external inner join credentialfielddef c on c.id = fieldid inner join vulture_commo o on o.vultureid = v.id inner join Commo q on q.id = o.vultureid where q.commotypeid like '4' order by userid Results look like this: UserId Firstname Lastname Crednetial Field Value GUID Jim Roberts Field1 Test1 GUID Jim Roberts Field2 Test2 GUID Jim Roberts Field3 Test3 GUID Jim Roberts Field4 Test4 Desired Result set: UserId Firstname Lastname Field1 Field2 field3 field4 GUID Jim Roberts Test1 Test2 Test3 Test4 The schema is nightmare and it took me a while just to get where I am now but I am stuck and need a little insight as to the best approach. I have tried using varibles and considered case statements but I am truely lost. Any help would be appreciated on the best method.

    Regards, Hulicat

    B 1 Reply Last reply
    0
    • H Hulicat

      Hello, I have the following query working well, however; I need to augment it and what seemed simple has really stumoed me. Maybe some of you can guide me in the right direction. use db1 select distinct v.userid, v.firstname, v.lastname, c.[name] as 'credential field', q.address, value from import3 inner join vulture v on v.userid = external inner join credentialfielddef c on c.id = fieldid inner join vulture_commo o on o.vultureid = v.id inner join Commo q on q.id = o.vultureid where q.commotypeid like '4' order by userid Results look like this: UserId Firstname Lastname Crednetial Field Value GUID Jim Roberts Field1 Test1 GUID Jim Roberts Field2 Test2 GUID Jim Roberts Field3 Test3 GUID Jim Roberts Field4 Test4 Desired Result set: UserId Firstname Lastname Field1 Field2 field3 field4 GUID Jim Roberts Test1 Test2 Test3 Test4 The schema is nightmare and it took me a while just to get where I am now but I am stuck and need a little insight as to the best approach. I have tried using varibles and considered case statements but I am truely lost. Any help would be appreciated on the best method.

      Regards, Hulicat

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

      How are stored your data on table, can you post here data on your table?


      I Love T-SQL "Don't torture yourself,let the life to do it for you."

      H 1 Reply Last reply
      0
      • B Blue_Boy

        How are stored your data on table, can you post here data on your table?


        I Love T-SQL "Don't torture yourself,let the life to do it for you."

        H Offline
        H Offline
        Hulicat
        wrote on last edited by
        #3

        I was able to accomplish the desired result via CASE statements. Thanks, Dennis

        Regards, Hulicat

        B 1 Reply Last reply
        0
        • H Hulicat

          I was able to accomplish the desired result via CASE statements. Thanks, Dennis

          Regards, Hulicat

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

          Coool...


          I Love T-SQL "Don't torture yourself,let the life to do it for 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