I am creating a distinct key by concatenating two different columns of a table. Now the key which I have created can be repeated, for example column A is roll number of student and column B is the optional subject in which he is enrolled. Now a student can be enrolled in multiple subjects as well as single optional subject, I want only those students roll number who are enrolled in only single optional subjects.
with the logic I am using I am getting the following error,
Message:ERROR: window functions not allowed in WHERE clause
Please help
SELECT
    CONCAT(roll_number, subject) as key,
    count (key) over(partition by key) as values
FROM
    subject_data
WHERE
    roll_number is not null and subject is not null
    and values = 1 
when I am using HAVING clause it is still throwing same error
 
    