sql - how to remove duplicate rows -
i have following query retrieve bunch of data somehow creates duplicate rows records.i tried distinct no use
what doing wrong here
select distinct dbo.tblassessmentecosystemcredit.managementzoneid, assessmentecosystemcreditid,dbo.tblassessmentecosystemcredit.assessmentversionid , (coalesce(dbo.tblmanagementzone.sitevaluecurrentscore,0) -coalesce(dbo.tblmanagementzone.sitevaluefuturescore,0)) lossinsitevaluescore, 5 savetype, dbo.ufn_varbintohexstr(dbo.tblassessmentecosystemcredit.rowtimestamp) rowtimestamp, dbo.tblvegetationzone.eecid, case when dbo.tblvegetationzone.eecid > 0 3.0 else 1.0 end eecoffsetmultiplier dbo.tblassessmentecosystemcredit inner join dbo.tblvegetationtype on dbo.tblassessmentecosystemcredit.vegtypeid = dbo.tblvegetationtype.vegtypeid inner join dbo.tblmanagementzone on dbo.tblassessmentecosystemcredit.managementzoneid = dbo.tblmanagementzone.managementzoneid inner join dbo.tblvegetationzone on dbo.tblvegetationzone.vegetationzoneid = dbo.tblmanagementzone.vegetationzoneid inner join dbo.tblassessmentversion av on av.assessmentversionid = dbo.tblassessmentecosystemcredit.assessmentversionid inner join tblassessment tba on tba.assessmentid = av.assessmentid dbo.tblassessmentecosystemcredit.assessmentversionid= @assessmentversionid
possibly have duplicate rows in central base table, dbo.tblassessmentecosystemcredit
. should easy check, know rows at.
more likely, obtaining multiple result rows corresponding few of dbo.tblassessmentecosystemcredit
rows because 1 of tables joining has multiple matches rows. is, 1 of these columns contains @ least 1 duplicated value:
dbo.tblvegetationtype.vegtypeid dbo.tblmanagementzone.managementzoneid dbo.tblvegetationzone.vegetationzoneid dbo.tblassessmentversion.assessmentversionid tblassessment.assessmentid
the responsible column must not subject single-column unique
constraint, , must not single-column primary key table, may narrow down. note whole row not need duplicated, id.