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. Select

Select

Scheduled Pinned Locked Moved Database
databaseregexhelpquestion
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.
  • N Offline
    N Offline
    niceguyeddie1999
    wrote on last edited by
    #1

    Hi, I have the following SQL: select a.codeid, b.codeidalias from tblcodes a left outer join tblcodeslookup b on a.codeid = b.codeid where a.codeid not in (select codeidalias from tblcodeslookup) and it produces the following kind of data codeid codeidalias 1 null 2 3 2 4 2 5 6 7 6 8 6 9 10 null 11 12 11 13 14 null if you can see the pattern. I have been trying for hours to modify it but i cant . Basically, of the codeids that appear more than once, I just want the first appear, ie. 1 null 2 3 6 7 10 null 11 12 14 null Can anyone help? Thanks in advance Eddie

    M 1 Reply Last reply
    0
    • N niceguyeddie1999

      Hi, I have the following SQL: select a.codeid, b.codeidalias from tblcodes a left outer join tblcodeslookup b on a.codeid = b.codeid where a.codeid not in (select codeidalias from tblcodeslookup) and it produces the following kind of data codeid codeidalias 1 null 2 3 2 4 2 5 6 7 6 8 6 9 10 null 11 12 11 13 14 null if you can see the pattern. I have been trying for hours to modify it but i cant . Basically, of the codeids that appear more than once, I just want the first appear, ie. 1 null 2 3 6 7 10 null 11 12 14 null Can anyone help? Thanks in advance Eddie

      M Offline
      M Offline
      Mike Ellison
      wrote on last edited by
      #2

      Try this (with a MIN and GROUP BY added):

      select a.codeid, MIN(b.codeidalias) as MinCodeIdalias from tblcodes a
      left outer join tblcodeslookup b on a.codeid = b.codeid
      where a.codeid not in (select codeidalias from tblcodeslookup)
      group by a.codeid

      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