ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Selecting duplicate records..

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Selecting duplicate records..

    Hi everyone...

    i want to select only the account numbers that have duplicate records in a file...

    how will i do it in sql? please teach! ^_^

    thnx

  • #2
    Re: Selecting duplicate records..

    this sql code will list all accounts with duplicate record:
    Code:
    select account#, count(account#) from yourfile group by account# having count(account#) > 1
    hope this helps.
    Greg

    Comment


    • #3
      Re: Selecting duplicate records..

      Originally posted by 9T96T9
      i want to select only the account numbers that have duplicate records in a file...
      Join the file on itself and check the Relative Record Number (RRN) on each.

      PHP Code:
      select RRN(T01), T01.Account,  RRN(T02), T02.Account 
      from MyFile T01 
      Join  MyFile T02
      On T01
      .Account T02.Account
      Where RRN
      (T02) <> RRN(T01
      Philippe

      Comment

      Working...
      X