I have a table that has the "document number" field, the type of flow (entering or leaving the country), date of birth, and the date the flow occurred.
Knowing that a person can leave or enter several times a year, how can I list those people (by their document number) of legal age (>=21yo) who were out of the country in a specific interval of the year (for example: between May 1, 2021 and August 1, 2021)?
ideally a syntax according to postgresql
EDIT: Info complement
where dates are yyy-MM-DD and should return:
because these people were out in the whole interval and has legal age.