如何获取产品数据,如果客户有未签约的产品,但有成交的产品

How to get product data, if the customer has non-signed products, but there are closing products

有一个产品 table 具有 client_id 和 status_id 字段 如何获得状态没有产品状态已签名且产品状态已关闭的客户

products
  id
  client_id
  status_id

本质上,您的问题建议聚合和 having 过滤子句。假设 status_id 1 已签名且 2 已关闭,则为:

select client_id
from products
group by client_id
having max(status_id = 1) = 0 and max(status_id = 2) = 1