title: How to compare the values for multiple rows in SQL
body: <p>I have a Source table as shown below..</p>
  
  <pre><code>Name    Subject Marks   Year
  
  A   Science 88  2015
  A   Social  75  2015
  A   Social  75  2015
  A   Maths   22  2015
  B   Social  75  2015
  B   Maths   50  2014
  C   Science 88  2015
  C   Social  75  2014
  D   Science 88  2015
  D   Social  75  2015
  A   Social  75  2015
  B   Maths   50  2014
  </code></pre>
  
  <p>and I have a requirement as below like if any student has satisfies both as in below requirements then he should be awarded as respected requirement set name in the another table B</p>
  
  <pre><code>Set1
  
  Social  75  2015
  Science 88  2015
  
  Set2
  
  Social  75  2015
  Maths   50  2014
  </code></pre>
  
  <p>The expected output in the table B is as below</p>
  
  <pre><code>Name    Status
  A   Set1
  B   Set2
  C   None
  D   Set1
  </code></pre>