title: SQL Query to Find specific output
body: <p>I have table like below:</p>
  <pre><code>SID     GRADE    SUBJECT
  1        C        ENG
  1        D        PHYSICS
  1        E        CHEMISTRY
  2        A        BIOLOGY
  2        B        ENG
  3        A        MATH
  4        B        PHYSICS
  4        C        MATH
  4        D        ENG
  </code></pre>
  <p>Output:
  If any of the record for a particular SID is having grade B, then consider only that line item, discard other line items for that particular SID.
  If any of the record for a particular SID isn't having grade B, then output all the line items for that SID.</p>
  <p>output will be look like as below:</p>
  <pre><code>SID     GRADE    SUBJECT
  1        C        ENG
  1        D        PHYSICS
  1        E        CHEMISTRY
  2        B        ENG
  3        A        MATH
  4        B        PHYSICS
  </code></pre>
  <p>Can anyone please assist me with the SQL Query? I'm using MS SQL Server</p>