PostgreSQL - ERROR: column does not exist SQL state: 42703
Solution 1:
SELECT renter_id,
Count(trip_finish) AS number_of_trips
FROM (
SELECT renter_id,
trip_finish,
Min(Date_part('year', created_at)) AS first_rental_year
FROM bookings
WHERE state IN ( 'approved', 'aboard', 'ashore', 'concluded', 'disputed' )
) T
WHERE first_rental_year = 2013
GROUP BY renter_id
ORDER BY renter_id ;