我有一个内部连接语句来获取在 3 个进程上运行并登录三个表的 id,
Select a.InquiryAccount ,a.InquiryAmount,a.InquiryCustName,a.InquiryLang, b.PayAmountPaid,b.PayScreenText,b.PayReceiptText, c.RevRefNo
from
inquiry a
inner join
Payment b
on a.InquiryAccount = b.PayAccount
inner join
Reversal c
on a.InquiryAccount = c.RevAccount
order by c.RevRefNo desc
它给出了我想要的结果,但是有些值加倍或重复,我想跟踪在内部连接结果上重复的帐户。
我尝试在我的内部连接上做这样的事情:
SELECT *
FROM Inquiry
WHERE InquiryAccount IN (
SELECT InquiryAccount
FROM Inquiry
GROUP BY InquiryAccount
HAVING (COUNT(InquiryAccount ) > 1)
)
显示唯一重复的帐户。但是当我尝试group by
它Inner Join
得到一个错误时,是否可以group by
打开inner join
?或者是否有任何关于在inner join
声明中发现重复值的解决方案?
这是我的内部连接语句的结果:
InquiryAccount InquiryAmount InquiryLang
10176601 124070 0
12344556 160050 1
10445654 160050 1
23456789 160050 1
22456666 160050 1
45324681 160050 1
14356890 160050 1
44566666 160050 1
22456666 160050 1
10176601 160050 1
这是我想从我的内部连接语句中生成的示例,它只获取重复的帐户:
InquiryAccount InquiryAmount InquiryLang
10176601 124070 0
10176601 160050 1
22456666 160050 1
22456666 160050 1