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

I need to display as,

Total No of employees

Officer, staff, Contact

total no of working hours:officer/total no of working hrs
staff/total no of working hrs

my code as:
SQL
select count(distinct Name) as NoOfPersons,sum(duration) as tot 
from Staff,Timesheet where Staff.StaffCategoryID='1'

it will multiply the NoOfPerson * tot

How to make a correction and find out the average for it

Help pl

Regards,
Pravin
Posted
Updated 21-Aug-11 23:26pm
v2

1 solution

it is pretty simple. you join the table Staff and Timesheet without stating what combines both tables.
Your query needs something like below:

SQL
select count(distinct Name) as NoOfPersons,sum(duration) as tot
from Staff as s,Timesheet as t 
where s.StaffCategoryID='1'
and s.fieldname = t.fieldname
 
Share this answer
 
v2

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