e6la3banoh
e6la3banoh

Reputation: 13

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

Upvotes: 1

Views: 68

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 173046

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

Upvotes: 1

Related Questions