title: SQL multiple conditions for group of data
body: <p>I am trying to write a validation for the following set of data:</p>
  
  <pre><code>SSYS | Material_Number | Characteristic | Description
  001  | 000000000001111 | SH_DESC        | TEST
  001  | 000000000001111 | DESIGN_TYPE    | NULL
  001  | 000000000001111 | VOLTAGE        | NULL
  001  | 000000000009999 | SH_DESC        | TEST2
  001  | 000000000009999 | OPER_METHOD    | LIGHT
  001  | 000000000009999 | FILTER_TYPE    | Filter element,Air
  001  | 000000000014560 | SH_DESC        | Horn,Signal
  001  | 000000000014560 | DIMENSION_SIZE | NULL
  001  | 000000000014560 | FILTER_TYPE    | NULL
  </code></pre>
  
  <p>I would like to group by the Material_Number and count as 1 (ie. true) if within the Material_Number group, the SH_DESC description is NOT NULL and all other characteristics' descriptions IS NULL. So, in this case my result would be:</p>
  
  <pre><code>SSYS | Material_Number | Characteristic | Description  | COUNT
  001  | 000000000001111 | SH_DESC        | TEST         |  1
  001  | 000000000009999 | SH_DESC        | TEST2        |  0 
  001  | 000000000014560 | SH_DESC        | Horn,Signal  |  1
  </code></pre>
  
  <p>My attempt:</p>
  
  <pre><code>Select COUNT (*), SSYS, Material_Number, Characteristic, Description
   From myDB where (Characteristic = 'SH_DESC' AND DESCRIPTION IS NOT NULL) AND (Characteristic NOT IN ('SH_DESC') IS NULL)
  GROUP BY SSYS, Material_Number, Characteristic, Description HAVING COUNT (*) &lt; 2
  </code></pre>
  
  <p>Any help is much appreciated!</p>