gpt4 book ai didi

sql - 选择不同的返回重复项

转载 作者:行者123 更新时间:2023-12-04 04:17:03 25 4
gpt4 key购买 nike

我有以下查询:

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 属性中的重复项。如果我删除其他属性一切正常。
例如
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.我的问题很简单,但我自己无法解决。
将非常适合任何形式的帮助。

最佳答案

试试这个:

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;

关于sql - 选择不同的返回重复项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27015408/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com