Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 25fc5ae

Browse files
authoredDec 27, 2020
Create number-of-calls-between-two-persons.sql
1 parent 23fad19 commit 25fc5ae

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
 
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Time: O(n)
2+
# Space: O(n)
3+
4+
SELECT LEAST(from_id,to_id) as person1,
5+
GREATEST(from_id,to_id) as person2,
6+
COUNT(*) as call_count,
7+
SUM(duration) as total_duration
8+
FROM Calls
9+
GROUP BY person1, person2
10+
ORDER BY NULL;

0 commit comments

Comments
 (0)
Please sign in to comment.