@SuppressLint("ValidFragment")
public ProductsFragment(String id) {
categoryID = id;
}
对于给定的客户ID,
如果批准该决定,则仅保留该客户的批准行。如果该客户没有任何批准的决定,则保留该客户的所有行。
期望输出
Customer Decision req_date
A Approved 2017-06-13
A Approved 2017-06-13
A Pending 2017-06-13
B Pending 2017-10-13
B Approved 2017-06-13
C Pending 2017-07-14
答案 0 :(得分:2)
我会使用or
:
select t.*
from t
where t.decision = 'Approved' or
not exists (select 1
from t t2
where t2.Customer = t.Customer and t2.decision = 'Approved'
);