title: SQL Server Query for Many to Many Relationship
body: <p>I have the following Many to many relationship (See the picture below) in my SQL server.</p>
  
  <p><img src="https://i.stack.imgur.com/yHbDJ.png" alt="Many to many relationship"></p>
  
  <p>In most cases there's are 2 rows in table tblWavelengths related to the table tblSensors, (in some cases only 1, and in extreme cases there can be 20 rows)</p>
  
  <p>I made the following simple query to retrieve the data from those 3 tables :</p>
  
  <pre><code>select W.DateTimeID,S.SensorName,S.SensorType,W.Channel,W.PeakNr,W.Wavelength
  from tblWavelengths as W
      Left Join tblSensorWavelengths as SW on W.tblWavelengthID = SW.WavelengthID
      Left Join tblSensors as S on SW.SensorID = S.SensorID
  order by W.DateTimeID
  </code></pre>
  
  <p>After running this query I got the following results :</p>
  
  <p><img src="https://i.stack.imgur.com/SdTty.png" alt="Result"></p>
  
  <p>Here comes my problem. I want to write a query which filters only those Sensors (SensorName) which at a given moment in time (DateTimeID) has two rows (two different wavelengths) in the tblWavelengths table. So for example I want to have the results without
  the 77902/001 Sensor - because it has only one row (one Wavelength) related to the tblSensors at a given moment in time </p>