2 Replies Latest reply on Jul 17, 2018 3:04 PM by none given

    Nested Joins

    none given

      Hello,

       

      I'm trying to compare two colleges.  I have 18 students (represented by the ID) that received scholarship offers.  Some students received scholarships from all schools, some received scholarships from only 1.  I want to compare the performance of two schools.  Selecting students that received offers from both schools AND committed to one of those two selected schools.

       

      How I would do it in SQL (not sure if syntax is perfect, sorry):

       

      SELECT state, 'Committed School' FROM example_player where 'Committed School' in ([First School Selector], [Second School Selector]) AND ID in (

      SELECT DISTINCT ID

      FROM (

      SELECT ID

      FROM example_offers WHERE SCHOOL = [First School Selector] ) a

      INNER JOIN (

      SELECT  ID

      FROM example_offers WHERE SCHOOL = [First School Selector]) b

      ON a.ID = b.ID

      )