Wednesday 15 May 2013

sql server - duplicate items in SQL view/query -


I am bringing some data together which is a view in SQL that I need to eliminate duplicate values ​​I I have tried to use separate and Group BY without success. Actually whatever we are running is a series of uploaded files which are based on the type of document associated with the provider. They will upload many versions of documents as it happens through different stages of the signature.

When they have added a new line in a new phase of more uploaded went document table of documents, RequiredDocumentsID are the same, but in UploadedFiles table file name (with the ID fields in the table) are new.

Historically, it is not an issue because we usually this information to see a provider at a time - in which case we just hold on one of the most recent for each document type . Now, however, we have to be a new page on which the once all providers must demonstrate, but each must once listed and will list only the most recent file name / path column.

Below this is the view that I have in the present, as I mentioned that the first value is a 'separate dabo' Rik Dastavejhkaidi 'is as well try to do as a Smuhbi are both researchers failed to eliminate any duplicates. I was considering an embedded selection or external, but my TSQL skill is not enough at that level yet.

  SELECT dbo.UploadedFiles.FileName, dbo.UploadedFiles.FilePath, dbo.ReqDocuments Pradataaidi, dbo.Providers.CompanyName, necessary documentation as dbo.ReqDocuments.ID, dbo.UploadedFiles.aDate , Dbo.UploadedFiles.aUser FROM dbo.Providers Join Inner Debo. Re-doc on Dbo.Providers.ID. Dbo.ReqDocuments.ProviderID INNER JOIN    

Simply put, it's a DocumentID given, you want a list of (ProviderID, FilePath) where FilePath that the recent DocumentID and ProviderID combination Are there.

I ordered by their filepaths division and dated by ProviderID all must rank: