如何计算gridview中的总执行时间? [英] how to calculate total execution hours in gridview ?

查看:90
本文介绍了如何计算gridview中的总执行时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

sql表包含
ID TestCase ExecutionTime
1测试1 5
2 Test1 10
3测试2 5
4测试3 6


从sql表中,我想在网格中将ExecutionTime显示为TotalHours TestCase不应重复,并且要像示例Test1 Total Hours 15那样进行计算和显示. 您好如何在gridview中计算总执行时间,例如:
------------- GridView ----------
ID  TestCase    TotalHours
1    Test1    
2    Test2
3    Test3

有人可以建议我该怎么做吗?

sql table contains
ID TestCase ExecutionTime
1 Test1 5
2 Test1 10
3 Test2 5
4 Test3 6


from sql table i want to show ExecutionTime in grid as TotalHours TestCase Should not be repeate and want to calculate and show like example Test1 Total Hours 15..
hi how to calculate total execution hours in gridview for example:
-------------GridView----------
ID  TestCase    TotalHours
1    Test1    
2    Test2
3    Test3

can any one suggest me how to do this?
thanks!!

推荐答案

SELECT LID, BuildNo, TID, Status, StarDate, EndDate, Sum(ExecutionTime)
FROM tblTestersWorkStatus
Group BY LID, BuildNo, TID, Status, StarDate, EndDate


将查询的输出提取到数据表中,然后将GridView数据源与此数据表绑定.


Fetch The Output of this query into Datatable and then bind the GridView Datasource with this datatable.


sample test use it will work for you :)

CREATE TABLE #test(id int,testcase varchar (10),ExecutionTime int)
INSERT INTO #test VALUES(1,'test1',2)
INSERT INTO #test VALUES(2,'test1',2)
select Row_number() OVER(order by TestCase) AS id, TestCase, SUM(ExecutionTime)
FROM #test
GROUP BY TestCase
drop table #test


关于您的查询您必须使用DateDiff()函数来确定日期值之间的执行时间.

请参见此处 [
On your query you have to use DateDiff() function to determine the excutiontime between to date values.

see here[^].


这篇关于如何计算gridview中的总执行时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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