本文介绍了为连接编写一个避免重复行的过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以前,我基于联接发布了一个问题,
但是在编写完程序之后,我发现重复的列还在进行中.
您能指导我如何使用分组依据"来避免重复吗?
谢谢您的答复,我必须学习新的概念.
Previously I have posted a question based on joins,
but after writing the procedures I found there are duplication of columns going on.
Can you please guide me how do I use "group by" to avoid the duplications.
Thank you for the response, I got to learn new concepts.
推荐答案
SELECT DISTINCT a.YearId, a.codeid, a.linkid, a.code, a.codename, a.AcctType,
b.CodeId, b.Code, b.CodeName,
c.Codeid, c.code, c.Codename,
d.FYId
FROM FinancialYear d, Accounts a
LEFT JOIN Accounts b ON(b.linkid=a.codeid)
LEFT JOIN Accounts c ON(c.linkid=a.codeid)
WHERE
a.YearId=d.FYId and
b.CodeId=a.CodeId and
a.linkid=6 and
a.CodeId=9 and
a.flag<>0 and
a.accttype='R'
干杯!
Cheers!
这篇关于为连接编写一个避免重复行的过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!