Click here to Skip to main content
16,008,490 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have two tables with a relation (table for Employees and table for Details) and a third table contains only (Id, Name ,Parent).


I want to have the sum of commission of the employee if he is male called male commission and the sum of commission of the employees if it is for female called it female commession.

How can I make that?

Thanks
Posted
Updated 13-Mar-11 10:57am
v2
Comments
Dalek Dave 13-Mar-11 16:57pm    
Edited for Grammar and Spelling.

1 solution

Hi,

I must admit that I didn't fully understand the question, but if you want to get a sum for detail rows based on gender in Employee your query could be something like:
SQL
select e.gender,
       sum(d.comission)
from employee e,
     detail d
where e.id = d.id 
group by e.gender;

Use the correct joining fields in the where-clause.
 
Share this answer
 
Comments
Dalek Dave 13-Mar-11 16:58pm    
Although why there would be a difference between male and female commission is a mystery, and probably illegal.
Sex Equality Laws sure prohibit such things?
Wendelius 14-Mar-11 0:53am    
That's true and hopefully that's not the case. However there could be a difference even without compromising the equality laws. For example if there's 5 women and 1 man in the employee. Then the summary would be 5 times greater for women.
moon2011 13-Mar-11 17:13pm    
that is an opnion, but i need that to make adifference betwwen sum of male and sum of female.
i want to know tha max to make that difference, how is it???

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900