'Query to sum calls

I have table contain call durations of a telecom company.

ex: Table 1

| callerid | receiverid  | call duration
| 1        | 2           | 5
| 1        | 2           | 2
| 2        | 3           | 4
| 1        | 5           | 2

i need to query above table so the result table after query:

Table 2

| callerid | receiverid  | call duration
| 1        | 2           | 7
| 2        | 3           | 4
| 1        | 5           | 2


Solution 1:[1]

use below

select callerid, receiverid, sum(call_duration) call_duration
from your_table
group by callerid, receiverid       

if applied to sample data in your question - output is

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mikhail Berlyant