title: Multiple Counts On Same Row With Conditions
body: <p>I am trying to calculate a summarised view of the data in my table, at the moment the query works but it isn't very efficient seeing as my table will eventually hold 10,000 + contracts.  I also need to filter each by the same date, I realise I could do this in the where statement for each count but this isn't very efficient.  </p>
  
  <p>Also the final calculation at the end would be much easier if I could operate on fields rather than selects.</p>
  
  <pre><code>(SELECT COUNT (*) FROM Contracts WHERE contractWon = 1) Won,
  (SELECT COUNT (*) FROM Contracts WHERE contractPassedToCS = 1) PassedtoCS,
  (SELECT COUNT (*) FROM Contracts WHERE contractPassedToCS = 0) as OutstandingWithSales,
  (SELECT COUNT (*) FROM Contracts WHERE contractIssued = 1) as ContractsIssued,
  (SELECT COUNT (*) FROM Contracts WHERE contractReturned = 1) as ContractsReturned,
  (CONVERT(decimal, (SELECT COUNT (*) FROM Contracts WHERE contractReturned = 1)) /         CONVERT(decimal, (SELECT COUNT (*) FROM Contracts WHERE contractIssued = 1))) * 100 as '% Outstanding'
  </code></pre>
  
  <p>I understand there is probably some joining needed but I'm a little confused. </p>
  
  <p>Thanks.</p>