title: Count min and max from a field
body: <p>I have table 1 like this:</p>
  
  <pre><code>number     p     uc_id     date
  3         1        g        24/09/2015
  4         0        g        24/09/2015
  5         1        g        24/09/2015
  5         1        f        25/09/2015
  3         0        f        25/09/2015
  5         1        g        26/09/2015
  </code></pre>
  
  <p>And a table 2 like:</p>
  
  <pre><code>id       name
  g        Magic
  f        Blue
  </code></pre>
  
  <p>I want that sql query returns something like</p>
  
  <pre><code>name      min     max
  Magic     1       2
  Blue      1       1
  </code></pre>
  
  <p>My query i have done something like date but i can't retrive the min and max</p>
  
  <pre><code>Select 
      p.date, 
      uc.name, 
      min((Select 
           uc.name, 
           count(p.p) 
           from table1 p, table2 uc 
           where p.p = 1 and uc.id = p.uc_id 
           group by uc.name, p.date)) as 'Min', 
      max((Select uc.name, 
           count(p.p) 
           from table1 p, table2 uc 
           where p.p=1 and uc.id = p.uc_id 
           group by uc.name, p.date)) as 'Max' 
  From table1 p, table2 uc
  Where uc.id = p.uc_id
  group by uc.name
  </code></pre>
  
  <p>I want to count the column p where p=1 and group by them by date and for each date i want to retrive the min and max of the count done prevously. Also showing the name in the other table.        </p>