I DON’t want to count NULL values. Because NULL should not be equal to NULL.
Look at this query result: link
WITH temp as (
SELECT 'A' as master , 1 Col from dual
UNION SELECT 'A' , 3 from dual
UNION SELECT 'B' , 1 from dual
UNION SELECT 'B' , 2 from dual
UNION SELECT 'C' , 1 from dual
UNION SELECT NULL , 1 from dual
UNION SELECT NULL , 2 from dual)
SELECT
master,
count(Col) over (partition by master)
FROM
temp
If you don’t want to filter out the rows where
masterIS NULL, you can do something likeSELECT master,
SUM( CASE WHEN master IS NULL
THEN 0
ELSE 1
END) OVER (PARTITION BY master)
FROM temp