Skip to content
Advertisement

SQL query to find out the single record by 3 conditions

Can you please help me with the query to find out the single record for the each student based on the subject.(Id,Name,subs are primary key). Ideally I will have 2 records for each subject. One with school TTT and MCC.

Table Structure:

I want the results

Advertisement

Answer

Here is one method using window functions:

This returns students with only one record. If you want student/subject combination with only one record, another method uses not exists:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement