1

I'm trying to write a query that will list the columns in a table when 3 specific fields are the same, but unknown:

TABLE:

FIELD 1  |   FIELD 2    |  FIELD 3   |   FIELD 4
---------|--------------|------------|---------------
  1      |   01-01-15   |    21      |     150
  1      |   01-01-15   |    24      |      12
  1      |   02-01-15   |    21      |     681
  1      |   01-01-15   |    21      |     299

DESIRED RESULTS:

    FIELD 1  |   FIELD 2    |  FIELD 3    |   FIELD 4
-------------|--------------|-------------|------------
      1      |   01-01-15   |    21       |     150
      1      |   01-01-15   |    21       |     299

Sorry - still a newb here! Thanks in advance!

Tom
  • 7,640
  • 1
  • 23
  • 47
DJDJ23
  • 139
  • 1
  • 2
  • 12

1 Answers1

3

Count the number of rows with the same combination and filter for a count > 1:

select *
from tab
qualify 
   count(*) 
   over (partition by field1, field2, field3) > 1
dnoeth
  • 59,503
  • 4
  • 39
  • 56