-- 이런식으로도 가능할겁니다.. WITH T ( 판매자 ,물품코드,판매가격) AS ( SELECT 'A','48', 110000 FROM DUAL UNION ALL SELECT 'A','103', 103000 FROM DUAL UNION ALL SELECT 'B','334', 106550 FROM DUAL UNION ALL SELECT 'B','243', 100000 FROM DUAL UNION ALL SELECT 'B','2', 5000 FROM DUAL UNION ALL SELECT 'B','234', 150000 FROM DUAL UNION ALL SELECT 'B','48', 110000 FROM DUAL UNION ALL SELECT 'C','16', 120000 FROM DUAL UNION ALL SELECT 'C','288', 103000 FROM DUAL UNION ALL SELECT 'C','636', 153000 FROM DUAL UNION ALL SELECT 'C','248', 103300 FROM DUAL ) SELECT * FROM T WHERE 판매자 IN ( SELECT 판매자 FROM T WHERE 판매가격 >= 10000 GROUP BY 판매자 HAVING COUNT(*) >= 4 );
SELECT *
FROM (
SELECT
T.*
,COUNT(CASE WHEN 판매가격 >= 100000 THEN 1 END) OVER(PARTITION BY 판매자) TC
FROM T
)
WHERE TC >=4