1

I have a table called enrollment. Student A has 3 records, with two of them have the same start_date.

I would like to find all the students with the same start date for the year 2013 in postgres.

Enrollment :

StudentID   Start_Date      Syear school_id
1             2013-06-21    2013    10
1             2013-06-21    2013    11 
1             2014-02-21    2014    10 

Thanks in advance.

1 Answer 1

1
SELECT StudentID, Start_Date
FROM
(
    SELECT StudentID, Start_date, COUNT(*) OVER (PARTITION BY start_date) count
    FROM Student
)
WHERE count > 1

or

SELECT StudentID, Start_Date
FROM Student S1
WHERE EXISTS (
    SELECT *
    FROM Student S2
    WHERE S1.Start_Date = S2.Start_Date AND S1.StudentID <> S2.StudentID
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.