I am trying to select rows from a table that have duplicates in one column but also restrict the rows based on another column. It does not seem to be working correctly.
select Id,Terms from QueryData where Track = 'Y' and Active = 'Y' group by Id,Terms having count(Terms) > 1 If I remove the where it works fine but I need to restrict it to these rows only.
ID Terms Track Active 100 paper Y Y 200 paper Y Y 100 juice Y Y 400 orange N N 1000 apple Y N Ideally the query should return the first 2 rows.
Id, is this column not unique in this table?