Complete the code to declare a column that stores time durations using the interval type.
CREATE TABLE events (duration [1]);The INTERVAL type in PostgreSQL is used to store durations or time intervals.
Complete the code to add 3 hours to the current timestamp using interval.
SELECT NOW() + [1] '3 hours';
Adding an INTERVAL value to a timestamp adds the specified duration.
Fix the error in the query that tries to subtract 30 minutes from a timestamp.
SELECT CURRENT_TIMESTAMP - [1] '30 minutes';
To subtract a duration, you must use an INTERVAL type.
Fill both blanks to create an interval of 2 days and 5 hours.
SELECT [2] '[1]';
The INTERVAL keyword is used with a string describing the duration, like '2 days 5 hours'.
Fill all three blanks to calculate the total duration in minutes from 1 hour, 30 minutes, and 45 seconds.
SELECT EXTRACT(EPOCH FROM ([1] + [2] + [3])) / 60 AS total_minutes;
Adding intervals and extracting epoch (seconds) then dividing by 60 gives total minutes.