title: Oracle query select sum count
body: <p>I have data from below query which looks like the first table below, here if you observe the results are based on count desc. I want to display the data in the form of second table and I am having trouble with the query. That is if pagetype is details,items I want to sum the count for that ID, and if pagetype is singe-item I want to leave it alone and order by all the results count desc. 
  First query gist looks like below, I have many other things in it but here is a simplified version of it.</p>
  
  <pre><code>SELECT id, title, count(id) as count_num , pagetype
  , ROW_NUMBER() OVER ( ORDER BY count(id) desc ) AS the_row 
  FROM table1, table2
  where  pagetype in ('details','items','single-item')
  and table1.id = table2.id 
  AND ct.PAGE_VIEW_DT &gt; sysdate - 90
  ORDER BY the_row
  
  
  ID             Title                     Count        pagetype
  --------------------------------------------------------------
  33969   TITLE ONE                         523         details
  33969   TITLE ONE                         494          items
  198068  TITLE THREE                       400       single-item
  33968   TITLE TWO                         395         details
  198068  TITLE THREE                       391          items
  198068  TITLE THREE                       333          items
  198068  TITLE THREE                       281         details
  33969   TITLE ONE                         280       single-item
  33968   TITLE TWO                         270       single-item
  
  
  ID             Title                     Count        pagetype
  --------------------------------------------------------------
  33969   TITLE ONE                        1017   details,items
  198068  TITLE THREE                      1005   details,items
  198068  TITLE THREE                       400   single-item
  33968   TITLE TWO                         395   details
  33969   TITLE ONE                         280   single-item
  33968   TITLE TWO                         270   single-item
  </code></pre>