本文介绍了选择不同的退货重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下查询:
SELECT
DISTINCT (TK.TICKETID),
TK.DESCRIPTION,
TK.CREATIONDATE,
TK.REPORTEDBY,
TK.OWNER,
WF.ASSIGNCODE
FROM ticket TK
INNER JOIN wfassignment WF on WF.OWNERID = TK.TICKETUID
WHERE TK.status not in ('ЧЕРНОВИК', 'ЗАКРЫТ', 'ВЫПОЛНЕН') AND WF.ASSIGNSTATUS not in ('COMPLETE', 'INACTIVE')
ORDER BY TK.TICKETID;
但是它在TK.TICKETID属性中返回重复项.如果我删除其他属性都可以.例如
But it returns duplicates in TK.TICKETID attribute. And if i remove other attributes all ok.e.g.
TK.TICKETID TK.DESCRIPTION TK.CREATIONDATE TK.REPORTEDBY TK.OWNER WF.ASSIGNCODE
О1013249 Право доступа 02.06.14 CHERNOVDK SKACHKOVSV NOVIKOVVA
О1013249 Право доступа 02.06.14 CHERNOVDK SKACHKOVSV PRITULADV
О1013249 Право доступа 02.06.14 CHERNOVDK SKACHKOVSV SVESHNIKOVAV
M.b.我的问题很简单,但我自己无法解决.任何帮助都会很棒.
M.b. my question is simple but I can't solve it by myself.Will be greatfull for any kind of help.
推荐答案
尝试一下:
SELECT
TK.TICKETID,
TK.DESCRIPTION,
TK.CREATIONDATE,
TK.REPORTEDBY,
TK.OWNER,
max(WF.ASSIGNCODE)
FROM ticket TK
INNER JOIN wfassignment WF on WF.OWNERID = TK.TICKETUID
WHERE TK.status not in ('ЧЕРНОВИК', 'ЗАКРЫТ', 'ВЫПОЛНЕН') AND WF.ASSIGNSTATUS not in ('COMPLETE', 'INACTIVE')
group by
TK.TICKETID,
TK.DESCRIPTION,
TK.CREATIONDATE,
TK.REPORTEDBY,
TK.OWNER
ORDER BY TK.TICKETID;
这篇关于选择不同的退货重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!