views:

22

answers:

1

Hi,

I want to select all of the rows added to a table which were added "yesterday" i.e. the day before whenever I choose to run the query.

At the moment my query looks like this:

SELECT row_date (etc)
WHERE  row_date >= trunc(sysdate-1)
       and row_date < truc(sysdate);

Is there a more efficient (and, hopefully, readable) way of achieving this?

Cheers,

Pete

+2  A: 

That query doesn't look like it can be optimised to me. You've made it sargable by avoiding wrapping the column itself in any date/time functions.

Do you have an index on row_date?

Martin Smith
I don't have an index on row_date at the moment.
Peter
@Peter - What RDBMS are you using?
Martin Smith
I am using Oracle
Peter