Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Multiple Calculations

Author  Topic 

ravininave
Posting Yak Master

111 Posts

Posted - 2010-04-05 : 13:17:19
How could I write this in SQL

Parameters
@CustCode
@CustAmount


Fetch CompanyRate,CompExpense,CompTax,Brokrage from MasterSettingTable
'--Will return ratio(%)

Fetch CustName,BossCode from CustMast where CustCode = @CustCode
@CustName=CustName
@BossCode=Bosscode '--Something like this

Fetch BossName,BossType from BossMast Where BossCode = @BossCode

Calculate Brokrage

dim Crate ,CExp,CTax, CompR, Comm

crate=(@CustAmount* CompanyRate)/100
CExp=(crate*CompExpense)/100
CTax =(crate*CompTax)/100

CompR= crate - (CExp+CTax) '--Final Rate after deduction of Expense and Tax
comm = (compR * Brokrage)/100

Insert into BrokTable
(BossCode,CustCode,CustName,Amount,Expense,Tax,MainAmt,Commission)
values
(@BossCode,@CustCode,@CustName,@CustAmount,CExp,CTax,CompR,comm)











VB6/ASP.NET
------------------------
http://www.nehasoftec.com

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-05 : 13:29:23
something like

SELECT @CustName=CustName,@BossCode=Bosscode from CustMast where CustCode = @CustCode

SELECT BossName,BossType from BossMast Where BossCode = @BossCode


...


I'm not sure where crate etc comes from but above will give u a start


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

ravininave
Posting Yak Master

111 Posts

Posted - 2010-04-05 : 14:31:41
quote:
Originally posted by visakh16

something like

SELECT @CustName=CustName,@BossCode=Bosscode from CustMast where CustCode = @CustCode

SELECT BossName,BossType from BossMast Where BossCode = @BossCode


...


I'm not sure where crate etc comes from but above will give u a start


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/





Thanx for hint. I got it


VB6/ASP.NET
------------------------
http://www.nehasoftec.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-05 : 23:59:37
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -