ALTER VIEW `v_stok` AS 
SELECT
  `v_stok_history`.`barang_id` AS `barang_id`,
  SUM(`v_stok_history`.`jumlah`) AS `stok`, 
  `barang`.`hpp` AS `hpp`,
  SUM(`v_stok_history`.`jumlah` * `barang`.`hpp`) AS `total_nilai`
FROM `v_stok_history`
join `barang` on `v_stok_history`.`barang_id` = `barang`.`id`
GROUP BY `v_stok_history`.`barang_id`;