Click here to Skip to main content
15,907,492 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using a SQL query in one datebase. The result is showing fine here. But when i use the same query for fetching the same data in another Database it showing duplication in data.


SELECT distinct ROW_NUMBER() OVER (ORDER BY r.Name) As SrNo, r.Place,rb.Address, r.PetName FROM tblA AS OW INNER JOIN tblB AS r INNER JOIN tblD AS s ON r.StatusId = s.StatusId INNER JOIN tblE AS rb ON r.tId = rb.tId ON OW.Id = r.Id INNER JOIN tblLookupWard AS LW INNER JOIN tblLookupLocation AS L ON LW.Id = L.Id INNER JOIN tblLookupCity AS city ON LW.Id = city.Id ON r.Id = L.Id
Posted
Comments
CHill60 6-Feb-13 8:35am    
These are all inner joins which leads me to ask ... does that other database actually have duplicate data in it?
__TR__ 6-Feb-13 8:35am    
Are you sure the query you have posted is correct ?
You seem to be missing a join condition in there.
FROM tblA AS OW INNER JOIN tblB AS r INNER JOIN
Member 9492907 6-Feb-13 8:39am    
Actually no need to consider the Query,bcoz it is working fine . I had given that Distinct , that is not working in one database.it showing duplication in data. plz help me to find it.

1 solution

Due to below code you getting duplicate vlaues, because you having duplicate data in another database. As your query you have duplicate r.Name but having different SrNo for it... so that it shows you duplicate row with having different SrNo..

ROW_NUMBER() OVER (ORDER BY r.Name) As SrNo

Thanks
If you find some help from it then plz mark as solution and vote it.
Hemant Singh
 
Share this answer
 
v3
Comments
Member 9492907 6-Feb-13 8:54am    
But it is working fine in my one database (same table details as the second one)..then what will be the issue
Hemant Singh Rautela 7-Feb-13 1:42am    
first check both table data without using DISTINCT keyword...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900