UndefinedReference
UndefinedReference

Reputation: 1253

Limiting SQL Results Based on Date

I'm not too familiar with the types of operations possible on SQL queries.

There's a line in the query that returns a value:

    trunc(sysdate) - trunc(\"DATE\") AS days_ago

I'm wondering if there's any way to have the query avoid returning any rows where 'days_ago' is greater than 365?

Thanks.

Upvotes: 0

Views: 30

Answers (2)

How 'bout a Fresca
How 'bout a Fresca

Reputation: 2317

Is there any reason adding this to the WHERE clause won't work:

WHERE (trunc(sysdate) - trunc(\"DATE\")) <= 365

?

You could also set a variable equal to trunc(sysdate) - trunc(\"DATE\") and perform your WHERE condition against that variable

Upvotes: 2

Guneli
Guneli

Reputation: 1731

You should add this to your query:

WHERE (trunc(sysdate) - trunc(\"DATE\"))<=365;

Upvotes: 2

Related Questions