This assumes that your five-minute intervals are, so to speak, "five." That is, you want 07:00, 07:05, 07:10, not 07:02, 07:07, 07:12. It also assumes that you do not have two lines in one minute, which may be unsafe.
select your_timestamp
from your_table
where cast(extract(minute from your_timestamp) as integer) in (0,5);
If you can have two lines with one minute timestamps, for example
2011-01-01 07:00:02
2011-01-01 07:00:59
then this version is more secure.
select min(your_timestamp)
from your_table
group by (cast(extract(minute from your_timestamp) as integer) / 5)
Wrap any of them in a view, and you can join it in your base table.
source
share