all groups > sql server programming > june 2005 >
You're in the

sql server programming

group:

calculating employee commission


Re: calculating employee commission --CELKO--
6/20/2005 2:32:48 PM
sql server programming: CREATE TABLE Commissions
(project_id CHAR(1) NOT NULL,
low_sales_pct DECIMAL (3.1) NOT NULL
high_sales_pct DECIMAL (4.2) NOT NULL
CHECK (low_sales_pct <= high_sales_pct),
commission_amt DECIMAL (4.2) NOT NULL,
PRIMARY KEY (project_id, low_sales_pct));

Now use a BETWEEN predicate: "Personnel.sales_pct BETWEEN low_sales_pct
and high_sales_pct"
Re: calculating employee commission Anith Sen
6/20/2005 4:50:33 PM
[quoted text, click to view]

You have to provide a relationship between the employee and the project;
without that, what determines Emp1 works on Project A?

[quoted text, click to view]

Given the right schema, the query is as simple as something like:

SELECT t1.Emp, MAX( t2.Commission )
FROM t1, t2
WHERE t1.project = t2.Project
AND t1.Sales > t2.Sales
GROUP BY t1.Emp ;

--
Anith

calculating employee commission ninel gorbunov via SQLMonster.com
6/20/2005 9:11:03 PM
I have the following tables:

Table1:
Emp %Sales
1 2.3

Table2:
Project %Sales CommissionAmt
A 2.2 1.50
A 2.4 1.75

Employee1 has 2.3 % sales.
I have to figure out from Table 2 which commission amount to apply. Because
emp1 has 2.3 I need to apply $1.50.

How do I do this in a query?

Thanks,
Ninel

--
AddThis Social Bookmark Button