title: How to merge records from two tables using group by clause in oracle?
body: <p>I have two tables ward1 and ward2ie;</p>
  
  <pre><code>create table ward1
  (
  ward_id int
  )
  
  create table ward2
  (
  ward_id int,
  ward_name varchar(10)
  )
  </code></pre>
  
  <p>and the values are --</p>
  
  <pre><code>insert into ward1 values(101);
  insert into ward1 values(101);
  insert into ward1 values(102);
  insert into ward1 values(102);
  insert into ward1 values(102);
  
  insert into ward2 values(101,'child');
  insert into ward2 values(102,'General');
  </code></pre>
  
  <p>So I need to produce total number of occurrence of ward_id.It was simple for me i used this  code.</p>
  
  <pre><code>SELECT ward_id, count(ward_id) as "No of occurrence" from ward1 group by ward_id;
  </code></pre>
  
  <p>the output was --</p>
  
  <pre><code>ward_id   No of occurrence
  101       2
  102       3
  </code></pre>
  
  <p>this are the records from ward1 table, but when I want ward_name from the table ward2. I am getting error.
  This is my code--</p>
  
  <pre><code>select ward1.ward_id as "ward_id",ward2.ward_name,
  count(ward1.ward_id)as "No of occurrence" from ward1,
  ward2 group by ward1.ward_id,ward2.ward_name 
  having ward1.ward_id=ward2.ward_id;
  </code></pre>
  
  <p>It says not a group by expression...</p>
  
  <p>I want to display like this--</p>
  
  <pre><code>ward_id   ward_name    No of occurrence
  101       child        2
  102       General      3
  </code></pre>
  
  <p>Please help....</p>