Add's referencefileid to the where clause on files, will only show you "real files" note files that have been linked to.