title: calculating on sum value at different table
body: <p><strong>This my code :</strong>  </p>
  
  <pre><code>SELECT barang.id_brg, barang.nm_brg, jen_sat, nm_kat, SUM( IFNULL(  stok_brg.stok, 0 ) ) AS stok, IFNULL( laku, 0 ) AS laku
          FROM barang
          JOIN satuan ON barang.id_sat = satuan.id_sat
          JOIN kategori ON barang.id_kat = kategori.id_kat
          LEFT JOIN stok_brg ON barang.id_brg = stok_brg.id_brg
          LEFT JOIN (
          SELECT barang.id_brg, SUM( IFNULL( brg_laku.dibeli, 0 ) ) AS laku
          FROM barang, brg_laku
          WHERE barang.id_brg = brg_laku.id_brg
          GROUP BY barang.id_brg ASC
          ) AS brg_laku ON barang.id_brg = brg_laku.id_brg
          GROUP BY barang.id_brg ASC
  </code></pre>
  
  <p><strong>Preview Of My Code:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/txCfd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/txCfd.png" alt="this preview of my code"></a></p>
  
  <p>the question is I want to make column stok - laku and make that result as column result can u guys get it sorry I was bad for my english so I don't know how to speak hope you guys can understand me Thanks  </p>