SQLTeam.com | Weblogs | Forums

Why i am getting duplicate in join

sql2012

#1

Hi ,

I have problem in fetching record in sql using join.If i have three table and two table contain duplicate record of first table then i am getting duplicate record .I want to avoid those duplicate record.

I attached problem image which describe my problem better.Please give me suggestion.How can i come out this problem?

thanks & regards,
shivam


#2

Add a group by clause at the very end of your query that includes all the columns in the select list as in

GROUP BY
t1.rno, t1.amt,t2.rno,t2.amt,t3.rno,t3.amt

If you add additional columns, for example qno, you will need to group by those as well. And when you do that, you will get more than one row for a given combination of mo and amt.