sqlimpalahue

How to fetch data of the last 10 minutes from datestamp?


I want to get the number of tweets that were tweeted in the last 10 minutes of the match. But to do that I need to select/get the last 10 minutes of my timestamp.

How can I do this in Impala/SQL?

This is what I currently have: What I have at the moment.


Solution

  • OK - If I understand from your comments now there is a separate tweets table, and you want to select the number of tweets 10 minutes before the game ended. I don't know the name of the tweets table, but something like this should work:

    select COUNT(*) from tweets t
    where t.tweet_date > 
    (select DATE_SUB(g.official_end, interval 10 minute)
     from game g where g.game_id = t.game_id) and t.game_id = 10