We will base the logic around sysdate which returns the current datetime, from which we substract units. For example for the last day from now use sysdate - 1 (defaults to day) and compare with the timestamp column (in this case CREATED_AT) : select count(*) from PARTNER WHERE CREATED_AT > (sysdate - 1) -- last 2 days would be select count(*) from PARTNER WHERE CREATED_AT > (sysdate - 2) From the last hour, respectively last two hours use the following commands, where 1/24 is the unit for hour...