Slavez
Slavez

Reputation: 239

How can I count elements with using timestamp

I have a timestamp value in my table and it's set to on update current timestamp.

It updates itself when user is doing x work.

I want to count how many users did x work in last 30 minutes. What's the mysql query that I need?

Upvotes: 0

Views: 76

Answers (1)

Fluffeh
Fluffeh

Reputation: 33512

You should use the count aggregate function your query

select 
    count(timestampColumnName) 
from 
    yourtable 
where 
    timestampColumnName>date_sub(now(), interval 30 minute)
    // and any other conditions as needed

Upvotes: 2

Related Questions