title: Count number of records logged by week - Oracle SQL
body: <p>I know this is relatively simple but I can't find a solution within the archives although i see similar ones but my SQL isn't adequate enough to reverse engineer them.</p>
  
  <p>All I am trying to do is count the number of calls raised within a team grouped by weeks from a call management table.  Here is an example of some code which returns a count of 30,000 plus entries.  I'd like to see that number divided down into weeks and also perhaps days based on a friday to friday range if possible?</p>
  
  <p><PRE>
  select COUNT(*) from opencall 
  where 
  trunc(to_date(substr(LOGDATE,1,10), 'DD-MM-YY')) BETWEEN '01-JAN-14' AND '31-DEC-14'
  </PRE></p>
  
  <p>The key fields are </p>
  
  <pre>
  logdate 
  </pre>
  
  <p>Table name is </p>
  
  <pre>
  opencall 
  </pre>
  
  <p>So I can then create a list of the number of calls logged by that suppgroup per week so</p>
  
  <pre>
  Week      Calls Logged
  Week 1       134
  Week 2       135
  Week 3       189
  ...
  ...
  </pre>
  
  <p>So quite simple but I could then use this code to do searches on all sorts of different fields to identify some patterns.</p>
  
  <p>All our date fields are VARCHAR2(20 BYTE) </p>
  
  <p>I can group this count by day simply enough using</p>
  
  <p><PRE>
      select COUNT(*), trunc(to_date(substr(LOGDATE,1,10), 'DD-MM-YY'))<br>
      from opencall 
      where 
      trunc(to_date(substr(LOGDATE,1,10), 'DD-MM-YY')) BETWEEN '01-JAN-14' AND '31-DEC-14'
      group by  trunc(to_date(substr(LOGDATE,1,10), 'DD-MM-YY')) 
      order by trunc(to_date(substr(LOGDATE,1,10), 'DD-MM-YY')) 
  </PRE></p>
  
  <p>Hopefully someone can help.</p>