select a.*, b.*,(select namagol from tm_golongan where kodegol=a.kodegol) as namagol,a.hargaavg,b.stockakhir*a.hargaavg as nilaibrg from tm_barang a, (select kodebrg,kodegd,sum(Stock0) Stock, sum(Stock1) Stock1,sum(Stock2) Stock2,sum(Stock3) Stock3,sum(stockakhir) stockakhir from tm_stockbrg group by kodebrg) b where b.kodebrg=a.kodebrg and a.jenisbrg= 'Proses' and ifnull(Aktif,'Y')='Y' order by a.kodebrg 
