Click here to Skip to main content
15,902,299 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
this is my query..but in this query TID is repeating..i dont want to repeat TID but want to calculate TID like example
TID    Date          ExecutionTime
Test1  10/2/2012         5
Test1  10/2/2012         5
Test1  10/4/2012         5
Test2  10/5/2012         10

think this s my sql table.. and i want to calculate Total time for every TID and TID should not be repeat..

SELECT DISTINCT Row_number() OVER (Order BY TID)LID,BuildNo,TID,Status,StarDate,EndDate,Sum(ExecutionTime)
AS ExecutionTime
from tblTestersWorkStatus
Group BY TID,LID,BuildNo,Status,StarDate,EndDate

but in this query m getty output like
for example
TID    Date        ExecutionTime
C#
Test1  10/2/2012         10

Test1  10/4/2012         5
Test2  10/5/2012         10



but i want calculation like
example:
TID      Date        ExecutionTime
Test1  10/2/2012   15

Test2  10/5/2012  10


Please ask if u have any doubt.??
Posted
Updated 21-Feb-12 17:50pm
v3

do not use row_number() with distinct

SELECT DISTINCT (TID) as TID , BuildNo,,Status,StarDate,EndDate,Sum(ExecutionTime)
AS ExecutionTime
from tblTestersWorkStatus
Group BY TID,LID,BuildNo,Status,StarDate,EndDate
 
Share this answer
 
Comments
ythisbug 21-Feb-12 23:54pm    
but also its repeating bro..i tried with only DISTINCT also.see i updated question
try this:-

select TID,Date,sum(ExecutionTime) [ET] from tblTestersWorkStatus group by TID,Date


[updated] As question is updated.
select TID,sum(ExecutionTime) [ET] from tblTestersWorkStatus group by TID
 
Share this answer
 
v2
Comments
ythisbug 21-Feb-12 23:59pm    
will get same out for your solution.as i gave query..query is different but output s same.thanks.any other solution?
Varun Sareen 22-Feb-12 0:27am    
I have updated the solution please see
ythisbug 23-Feb-12 6:11am    
bro can i get some other solution for this.in my sql table Status column is der in that values as In Progress ,Not Started,Completed

and there are many records for In Progress and Completed here calculating for that query as In Progress and Completing in Different
Varun Sareen 22-Feb-12 0:23am    
Friend, Don't fetch the column Date in your query and then group by on the TID.. you will get the results you require.
ythisbug 22-Feb-12 0:36am    
what u mean by [ET]?

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