Take 5 minute averages from second data
(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);
")