Results 1 to 3 of 3

Thread: Need SQL Query

  1. #1
    Join Date
    Jun 2010
    Posts
    1

    Unanswered: Need SQL Query

    I have a Table as follows

    Table (F1 is Primary Key)

    F1 F2 F3
    1 A 20
    2 A 20
    3 B 10
    4 B 40
    5 c 50
    6 A 30

    I need to select the rows which has duplicate in F2 and F3

    I need a sql query which only select the following results only

    F1 F2 F3
    1 A 20
    2 A 20

    Here F1 is a primary key in the table.

  2. #2
    Join Date
    Mar 2009
    Location
    Australia
    Posts
    113
    Code:
    Select	TT.F1,
    	TT.F2,
    	TT.F3
    From	testtable TT
    Join	(
    		Select		F2,
    				F3
    		From		testtable
    		Group By 	F2,
    				F3
    		Having		Count(F1) > 1
    	) Table2
    On	Table2.F2 = TT.F2
    And	Table2.F3 = TT.F3

  3. #3
    Join Date
    Jun 2010
    Posts
    1
    thanks

    Select TT.F1,
    TT.F2,
    TT.F3
    From testtable TT
    Join (
    Select F2,
    F3
    From testtable
    Group By F2,
    F3
    Having Count(F1) > 1
    ) Table2
    On Table2.F2 = TT.F2
    And Table2.F3 = TT.F3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •