title: SQL Oracle query to calculate subtotal
body: <p>I am googling to find proper way to make subtotals in Oracle SQL. Recording to this i make query </p>
  
  <pre><code>select model,  sifra, velicina, sum(nvl(magacin,0)) as suma
  from podmornica
  where model ='30001'
  group by  sifra, velicina, cube (model)
  order by model, sifra, velicina
  </code></pre>
  
  <p>I have table podmornica with columns:model,  sifra, velicina, magacin</p>
  
  <p>But it doesn't work. Every second row in column model is null, and at the end  not calculate sum. How to solve this?
      Thanks</p>
  
  <p>P.S. In one MODEL we have variations of SIFRA, i wan't as result to have subtotals for each SIFRA for one model (in this case model is 30001). Like below</p>
  
  <pre><code>MODEL  SIFRA     VELICINA  SUMA
  
  30001  3000101      0        1
  30001  3000102      0        2
  30001  3000103      0        5
  ______________________________
  30001                        8
  </code></pre>