Sql query help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sants
    New Member
    • Oct 2006
    • 1

    #1

    Sql query help

    I need some help with an sql statement that i've been trying to run.

    I have a db table on Oracle 8i with the following fields

    sqno, f1, f2, f3, f4, f5, f6

    Only the sqno field have unique values in them. The rest of them may have duplicate values

    Firstly i need to find unique combinations of values in fields f1, f2 and f3. This is easy using the SELECT DISTINCT f1, f2, f3 command

    But what i need is the corresponding sqno and f4, f5 and f6 values in the result

    I then need to delete all rows that are not reported in the above result.

    How do i achieve this via sqlplus 8.1.7

    Thanks

    Sants
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    This is an Oracle question. Thread moved

    Ronald :cool:

    Comment

    • jainarayan5484
      New Member
      • Oct 2006
      • 5

      #3
      i think this query will help u

      delete from T_name c Where (c.sqno,c.f4,c. f5,c.f6) not in (Select b.sqno,b.f4,b.f 5,b.f6 from T_name b,(Select distinct f1,f2,f3 from t_name) a
      Where (b.f1,b.f2,b.f3 )=(a.f1,a.f2,a. f3))

      Comment

      Working...