Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE source
- AS
- SELECT *
- FROM ( VALUES
- ( 6, 1000 ),
- ( 6, 2000 ),
- ( 7, 5000 ),
- ( 7, 6000 )
- ) AS t(client_id, score);
- client_id | score
- ----+---------+---
- 6 | 3000
- 7 | 11000
- CREATE VIEW desired_view
- AS
- SELECT client_id, sum(score)
- FROM source
- GROUP BY client_id;
- client_id | sum
- -----------+-------
- 6 | 3000
- 7 | 11000
- (2 rows)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement