Hi All,
Having a bit of a "special" moment here. Basically I have a DB table for listing files and their attributes (size, creation date, etc). Being a self-proclaimed (borderline delusional) SQL-whiz, you can imagine my surprise when I failed to figure out a quality manner by which to individually list only files whose [INSERT ATTRIBUTE HERE] appeared multiple times.
For instance, say I wanted to see all files whose file size (or creation date) appeared more than once in the table, but I still wanted them listed separately. Or an even better application: a group of files that share MD5 hashes, but only ones that appear multiple times (i.e. duplicates), and I still want to list each file independently. Obviously I could loop through the DB multiple times, but I'm interested in a single query. Any thoughts?
Best.
[EDIT #1 (error in count)]
select *
from @foo where FileNameOnDisk in (
select FileNameOnDisk, count([INSERT_ATTRIBUTE_HERE]) as num from @foo
group by FileNameOnDisk
having num > 1
)order by FileNameOnDisk