title: Grouping records and excluding
body: <p>I have a single table name Products with columns:</p>
  
  <pre><code>ProductID int, 
  ProductName varchar(50), 
  FromDate DATETIME, 
  ToDate DATETIME, 
  Modified DATETIME,
  ModifiedBy int
  </code></pre>
  
  <p>This table contains same <code>ProductNames</code>. <code>Modified</code> is also a <code>date</code> type column which tells about any changes made to the product on that <code>Modified</code> <code>date</code>. When any change is made to the product <code>ToDate</code> and <code>Modified</code> will be updated according to the change other wise both will be <code>null</code></p>
  
  <p>Now my requirement is :</p>
  
  <ul>
  <li>I want a <code>productname</code> having <code>ToDate</code> with a value
  and also with <code>null</code> in two columns </li>
  <li>Excluding those <code>Productname</code> with no change means having only <code>ToDate</code> and <code>Modified</code> as <code>NULL</code></li>
  <li>Need Result set of Loca and Mocca</li>
  </ul>
  
  <p>I have tried this code </p>
  
  <pre><code>select  *     
  from     Products cpp with (nolock)  
  where   (TODATE is not null and Modfied is not null)        
          or (TODATE is null and Modified is null)  
  order by ProductID desc
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/QUNTu.jpg" rel="nofollow noreferrer">Table Data</a></p>