Snatch any course you want for just $15! Go to “Courses” and find a course ↓
Introduction
Side-effects in functions
Invoking functions

Instruction

Good job! It's quite common for a query or function to return multiple columns. You can use SELECT INTO statement to assign multiple values in one query.

You can use this syntax with an SQL query:

SELECT posted_timestamp, deleted_timestamp
INTO created, deleted
FROM post WHERE id = post_id;

Or you can use this syntax with a function:

SELECT posted_timestamp, deleted_timestamp
INTO created, deleted
FROM get_users_first_post(user_id);

Exercise

Write a function named get_post_score() with one input parameter post_id of type integer. The function should return the difference between the post's upvotes and downvotes (use SELECT INTO to select thumbs_up and thumbs_down for the post in a query).