Take 5 minute averages from second data I want to preface this post by saying that I am a complete newbie with SQL and any help will be highly appreciated.

For some project I am working with high frequency stock data, below is a small sample of what it looks like in the SQLite database

SYMBOL  DATE        TIME        PRICE
AAPL    19990602    15:59:54    46,50000
AAPL    19990602    15:59:59    46,56250
AAPL    19990602    16:00:00    46,56250
AAPL    19990603    09:30:03    46,87500
AAPL    19990603    09:30:04    46,81250
AAPL    19990603    09:30:05    46,84375


I do not want to analyze this on a second basis but rather on a 5 minute basis. I want to take the 5 minute averages from this day. So I want to take the average from 

9:30:00 - 9:34:59 -&gt; 5 min average price for 9:35:00 (first point)
9:35:00 - 9:39:59 -&gt; 5 min average price for 9:40:00
...
15:55:00 - 15:59:59 -&gt; 5 min average price for 16:00 (last point)


My first idea (and possibly not the most efficient one) was to make a list of each second with the corresponding index of the 5 minute interval it belongs to 

TIME    SEGMENT
09:30:00    1
09:30:01    1
09:30:02    1
   …        …
09:34:59    1
09:35:00    2
09:35:01    2


I was wondering if anyone of you could answer this question or point me in the right direction towards which SQLite commands I should look into as this is my first encounter with SQlite and I feel a bit overwhelmed.
(Moved here from an edit on the question: Reddit helped me out with this already. Eventually I used this code)

fiveminaverage &lt;- dbGetQuery(db,"
SELECT DATE, AVG(PRICE), MIN(TIME) AS firstSample, MAX(TIME) AS lastSample
FROM currentdata
WHERE DATE=19990603
GROUP BY DATE, strftime('%s', (CASE WHEN TIME LIKE '_:__:__' THEN '0' || TIME ELSE TIME END)) / (5 * 60);
")