Click here to Skip to main content
15,918,303 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I had created one Task Master web form in asp.net using c#....in which i had one column as Spent Hours for the particular task of particular employee....so to fetch the total numbers of spent hours i wrote the sql query as

Select Count(Spenthrs) from Task_Master where Eid='PS103' and Tname='t1';

for example...

if PS103 numbered employee perform task t1 and he spent 2 hours one day,5 hours on another day,3 hrs on the next day etc... then total numberof spent hours should be 10...but the above query which i wrote give me count as 3...so what will be right sql query syntax for this...???
Posted
Updated 31-Mar-14 18:41pm
v2

SUM(Spenthrs) not COUNT(Spenthrs)
 
Share this answer
 
It should be:

Select SUM(Spenthrs) from Task_Master where Eid='PS103' and Tname='t1';

the count "counts" the number of "entries" (rows) in your task manager, while you should be "summing" these hours.
 
Share this answer
 

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