2017-01-21 29 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中的查询。 等等...