通过窗口函数将供应商的数量与最小值和最大值进行比较,并在外部查询级别上运行条件计数:
SELECt vendor_id , count(min_bid OR NULL) AS min_bid_count , count(max_bid OR NULL) AS max_bid_countFROM ( SELECt vendor_id , amount = min(amount) OVER w AS min_bid , amount = max(amount) OVER w AS max_bid FROM rfq_vendor_mapping WINDOW w AS (PARTITION BY rfq_id) ) subGROUP BY 1ORDER BY 1;
SQL。



