noahabe / database_system_concepts_answers

🗄️ Solutions to Database System Concepts Seventh Edition
MIT License
437 stars 99 forks source link

There's some problem with the solution for questions 3.31 and 3.32 #16

Open roseblooming opened 6 months ago

roseblooming commented 6 months ago

My answers are as follows:

    #3.31
    select ID,name
    from instructor
    where ID not in (
        select ID
        from teaches
        where (course_id,sec_id,semester,year) in (
            select course_id,sec_id,semester,year
            from takes
            where grade like 'A%'));
    #3.32
    select instructor.ID,name
    from (instructor natural join teaches) join takes 
    using (course_id,sec_id,semester,year)
    where grade is not null 
    and not exists (select *
                    from teaches join takes 
                    using (course_id,sec_id,semester,year)
                    where teaches.ID=instructor.ID 
                    and grade like 'A%')
noahabe commented 6 months ago

I will definitely look into it 🙏.