SQL 查询一部分字段重复,另一个字段不重复的写法:
StaffId,ReceiptNo,BalanceOfLoan,Date123456,999999,200,2017-02-31123456,999998,500,201...
StaffId, ReceiptNo,BalanceOfLoan,Date
123456,999999,200,2017-02-31
123456,999998,500,2017-02-31
123456,999999,100,2016-12-31
需要取出的记录:123456,999999,200,2017-02-31
有一次查询就可以搞定的吗? 10万条记录过滤 子查询太耗时间
目前都做法
Seletc * From Table Where Date='2017-02-31' And ReceiptNo in
(Seletc ReceiptNo From Table GROUP BY ReceiptNo COUNT(*)=2) 展开
123456,999999,200,2017-02-31
123456,999998,500,2017-02-31
123456,999999,100,2016-12-31
需要取出的记录:123456,999999,200,2017-02-31
有一次查询就可以搞定的吗? 10万条记录过滤 子查询太耗时间
目前都做法
Seletc * From Table Where Date='2017-02-31' And ReceiptNo in
(Seletc ReceiptNo From Table GROUP BY ReceiptNo COUNT(*)=2) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询