2017-01-21 57 views
0
Tax1 = SELECT a.harga_triumph * b.nilai_desimal 
from tbl_detail mc a 
JOIN penyesuaian b on a.id=b.id 

Tax2 = Tax1 * (c.nilai_desimal from bea_masuk where kode='BM') 

Tax3 = c.nilai_desimal from bea_masuk where kode='PPNImpor' * (Tax1 + Tax2) 

Tax4 = c.nilai_desimal from bea_masuk where kode='PPNBM' * (Tax3) 

Tax5 = c.nilai_desimal from bea_masuk where kode='PRH' * (Tax3) 

AllTax = Tax2 + Tax3 + Tax4 + Tax5 

Total Price = a.harga_triumph + All Tax 

where [email protected] 

我被困在使這個查詢使用函數。函數含參數的查詢

翻譯:

harga_triumph = unit price 
nilai_desimal = decimal (0.1,0.2) 
penyesuaian = adjustment 

SQL小提琴:http://sqlfiddle.com/#!9/31244/1

+0

[爲什麼「有人可以幫我嗎?」不是一個實際的問題?](http://meta.stackoverflow.com/q/284236) – EJoshuaS

回答

0

我已經不使用的功能解決了這個問題,我只是用在查詢一個簡單的設置是這樣的

set @dectax1 = (select round(nilai_desimal,3) from bea_masuk where id=1; 
set @tax1 = (select round(harga_triumph * @dectax1)); from tbl_detail_mc where id=1); 

如果要顯示結果,請使用@ tax1中的查詢。 等等...