I have this general idea to find duplicate values taken from this post: Select statement to find duplicates on certain fields
select field1,field2,field3, count(*)
from table_name
group by field1,field2,field3
having count(*) > 1
this works great to find the duplicates, but i need to also pull out a unique number, in this case an "order number" column that goes along with each row returned. This unique value cannot be used in the method above, because that would then return no rows as none would be exact duplicates. I need to be able to return this data but also find the records that occur multiple times in a table. I think this can be done with a union or using exists, but not sure how that would be accomplished. Any ideas?
sample result idea:
order number, field1, field2, field3
123 a b c
456 d e f
789 a b c
would want it to return order numbers 123 and 789 like this:
order number, field1, field2, field3
123 a b c
789 a b c