我想计算特定员工花费的总小时数....那么sql查询会是什么? [英] I want to calculate total number of hours spent by the particular employee ....so what will be the sql query?

查看:78
本文介绍了我想计算特定员工花费的总小时数....那么sql查询会是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用c#....在asp.net中创建了一个Task Master Web表单,其中我有一列作为特定员工的特定任务的花费时间....所以要获取花费的小时总数我写了sql查询为



从Task_Master中选择Count(Spenthrs),其中Eid ='PS103'和Tname ='t1';



例如...



如果编号为PS103的员工执行任务t1,他一天花了2个小时,另一天花了5个小时,第二天3小时等...然后花费的小时总数应该是10 ...但是我写的上述查询给我算作3 ...所以这对于SQL查询语法是什么...? ??

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...???

推荐答案

SUM(Spenthrs)不是 COUNT(Spenthrs)


它应该是:



从Task_Master中选择SUM(Spenthrs),其中Eid ='PS103'和Tname ='t1';



计数计数条目的数量(行s)在你的任务经理中,你应该总结这些时间。
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.


这篇关于我想计算特定员工花费的总小时数....那么sql查询会是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆