从文件编号栏中选择所有重复凭证编号,如果它在分配栏中有重复的条目,则选择该文件编号。
说:
Document No
111
123
121
111
111
Distribution
AAA
BBB
AAA
ABC
AAA
结果
111 AAA
111 AAA
答案 0 :(得分:0)
首先使用group by
和having clause
select * from table where (Document_No,Distribution ) in (
select Document_No,Distribution from table
group by Document_No,Distribution having count(*) >1
)
或
select t1.Document_No,t1.Distribution from table t1 join
(select Document_No,Distribution from table
group by Document_No,Distribution having count(*) >1
) as t2 on t1.Document_No=t2.Document_No and t1.Distribution=t2.Distribution
答案 1 :(得分:0)
这是一个可能的解决方案:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// fetch data in background thread
});
答案 2 :(得分:0)
SELECT
[Document No],
Distribution
FROM Document
GROUP BY [Document No], Distribution
HAVING COUNT(*) > 1