Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 ADD command

Author  Topic 

shan1430
Yak Posting Veteran

86 Posts

Posted - 2008-06-19 : 02:18:25
Hi,
I have 5 columns in a table called B. 2 of it is Time and User.
how do i add the all the time for an user and insert it into a table called C with columns User and Totaltime? For example,

Table B
Time......User
0.2........A
0.2........A
0.3........B
0.4........B

so my table C should be as follows,

Table C
User....Totaltime
A...........0.4
B...........0.7

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-19 : 02:20:23
[code]INSERT INTO C (User,TotalTime)
SELECT User,SUM(Time)
FROM B
GROUP BY User[/code]
Go to Top of Page

shan1430
Yak Posting Veteran

86 Posts

Posted - 2008-06-19 : 02:34:45
thanks
Go to Top of Page
   

- Advertisement -