title: Fetch data in MS SQL 2008
body: <p>I have three tables which are like:</p>
  
  <pre><code>table1
   id,
   created_Date
  
  table2
   id
   district_ID
   status_ID
  
  table3
   district_ID
   district_Name
  </code></pre>
  
  <p>Now i need the records in following format</p>
  
  <pre><code>Srno  District_name     &lt;10 days        &gt;10 and &lt;20 days       &gt;20 days
  
  1     xxx               12               15                    20
  2     yyy               8                0                     2
  </code></pre>
  
  <p>count days as per current date </p>
  
  <p>for example: if the created date is 10-08-2013 and current date is 13-08-2013 the date difference will be 3</p>
  
  <p>So what should my query be? Any suggestions will be appreciated.</p>
  
  <p>Thank you </p>
  
  <pre><code>table1
  
  id      created_Date
  1       2013-07-12 13:32:10.957
  2       2013-07-12 13:32:10.957
  3       2013-08-01 10:00:10.957
  4       2013-08-10 13:32:10.957
  5       2013-08-10 14:32:10.957
  
  
  table2
  
  id      district_ID   status_id
  1       1             3
  2       2             3
  3       2             7
  4       3             4
  5       4             3
  
  table1
  
  district_ID    district_Name
  1              xxx
  2              yyy
  3              zzz
  4              aaa
  5              bbb
  </code></pre>