title: Combining output rows by date
body: <p>I have a following problem with PL/SQL..</p>
  
  <p>I need to retrieve data from the table for various parameters, for the certain time period, but on the output I have duplicates for dates providing me an output for each column, but not combining them together. Could I please borrow your geniuses for this issue? </p>
  
  <p>Here is my code (part of it, as it repeats the same for other parameters I need to deliver):</p>
  
  <pre><code>select /*+FULL(k)*/ k.date_n,
  
   SUM(decode(bucket_flag_n,
          '1',
          (DECODE(type_s,
                      'MOC',
                      decode(on_off_net_s, 'On net', duration_sum),
                      'MOC_4',
                      decode(on_off_net_s, 'On net', duration_sum),
                      'MOC CF_4',
                      decode(on_off_net_s, 'On net', duration_sum),0)))) test1,
  
   SUM(decode(bucket_flag_n, 
           '0',
           (DECODE(type_s, 
                       'MOC',
                       decode(on_off_net_s, 'Off net', duration_sum),
                       'MOC_4', 
                       decode(on_off_net_s, 'Off net', duration_sum), 
                       'MOC CF_4', 
                       decode(on_off_net_s, 'Off net', duration_sum),0)))) test2
  
    from (select /*+FULL(a)*/
           a.d_timestamp date_n,
           a.service_s type_s,
           a.country_s,
           a.on_off_net_s,
           a.bucket_flag_n,
           round(SUM(a.duration_n / 60)) duration_sum, --minutes rounded
           SUM(a.count_n) sms_count, -- sms count
           round(SUM(a.volume_n / 1024 / 1024)) volume_sum -- volume mb rounded
  
            from database a, database2 b
  
           where a.country_s = 'Country'
             and a.free_of_charge_flag_n = '1'
             and a.d_timestamp between b.date_from and b.date_to
           group by a.d_timestamp,
                    a.service_s,
                    a.country_s,
                    a.on_off_net_s,
                    a.bucket_flag_n) k
  
   group by k.date_n, bucket_flag_n
   order by 1
  </code></pre>
  
  <p>Here is what I gt on the output:</p>
  
  <p><img src="https://i.stack.imgur.com/nWaUK.png" alt="http://imgur.com/z4DGdtO"></p>
  
  <p>Thank you in advance!</p>