title: SQL Select: multiple customers have muliple order lines. list each customer and true false whether certain lines ordered
body: <p>I have a SQL Server 2005 table which lists customers and their order lines like this...</p>
  
  <pre><code>Cust  | Code 
  Cust1   N001
  Cust2   N001
  Cust2   N003
  Cust2   N004
  Cust3   N001
  Cust3   N002
  Cust3   N003
  Cust3   N004
  </code></pre>
  
  <p>I need the results to list each customer (Once) and whether they have ordered ANY items between N002 and N004. The results would therefore look like this...</p>
  
  <pre><code>Cust  | Ordered?
  Cust1   False
  Cust2   True
  Cust3   True
  </code></pre>
  
  <p>I have tried various combinations of All / ANY etc. The closest I got was using two queries. In the first I would add the following to get a true/false statement to the end of each line ... </p>
  
  <pre><code>SELECT 
      Cust, Code, 
      CASE 
          WHEN Code BETWEEN 'N002' AND 'N004' THEN 'True' 
          ELSE 'False' 
      END AS Expr1 
  </code></pre>
  
  <p>This gives the following...</p>
  
  <pre><code>Cust  | Code | EXPR1
  Cust1   N001   FALSE
  Cust2   N001   FALSE
  Cust2   N003   TRUE
  Cust2   N004   TRUE
  Cust3   N001   FALSE
  Cust3   N002   TRUE
  Cust3   N003   TRUE
  Cust3   N004   TRUE
  </code></pre>
  
  <p>Then using a second query and grouping the results I get </p>
  
  <pre><code>Cust  | Ordered?
  Cust1   False
  Cust2   False
  Cust2   True
  Cust3   False
  Cust3   True
  </code></pre>
  
  <p>So could any one help to achieve simply...</p>
  
  <pre><code>Cust  | Ordered?
  Cust1   False
  Cust2   True
  Cust3   True
  </code></pre>