tags:

views:

120

answers:

1

I'm not very good in SQL stuff, so I hope someone can explain this issue to me (and help me solve it)

I have a table;

++++++++++++++++++++
|  ID  |  Minutes  |
++++++++++++++++++++
| 1012 |    15     |
| 1012 |    25     |
| 1015 |    45     |
| 1016 |    10     |
| 1016 |    50     |
++++++++++++++++++++

And I want to achieve, that the table will be transferred, so every ID is unique, but the minutes are added up and it then looks like this:

++++++++++++++++++++
|  ID  |  Minutes  |
++++++++++++++++++++
| 1012 |    40     |
| 1015 |    45     |
| 1016 |    60     |
++++++++++++++++++++

The table is a view of the original table, the calculation of the minutes is done with "DATEDIFF" - probably this will help...

+5  A: 
SELECT ID, Sum(Minutes)
FROM MyTable
GROUP BY ID
Mitch Wheat
@Mitch, add 'From Sometable' ??
Charles Bretana
Not necessary, I can figure that out myself ;-)
ApoY2k
@Mitch, Easy one. :)
Guru
@Charles Bretana: Thanks!
Mitch Wheat